Date Format Issue In Android When Locale Is Arabic
Solution 1:
You can use:
Calendar.set(intyear, intmonth, intday, int hourOfDay, intminute, intsecond)
Sets the year, month, day of the month, hour of day, minute, and second fields. Other fields are not changed; call clear first if this is not desired. The month value is 0-based, so it may be clearer to use a constant like JANUARY. Like this:
Calendarcal= Calendar.getInstance(Locale.US);
publicvoidonDateSet(DatePicker view, int year, int month, int day) {
cal.set(year, month, day, 0, 0, 0);
// get time in millisecondsLongtimeInmilliseconds= cal.getTimeInMillis();
// print time
Log.v("log", "Date "+ newDate(cal.getTimeInMillis()));
}
Also see this:
A common mistake is to implicitly use the default locale when producing output meant to be machine-readable. This tends to work on the developers test devices (especially because so many developers use en_US), but fails when run on a device whose user is in a more complex locale. For example, if you are formatting integers some locales will use non-ASCII decimal digits. As another example, if you are formatting floating-point numbers some locales will use ',' as the decimal point and '.' for digit grouping. That is correct for human-readable output, but likely to cause problems if presented to another computer (parseDouble(String) cannnot parse such a number, for example).
Post a Comment for "Date Format Issue In Android When Locale Is Arabic"