The Locale can be specified only at creation of a Calendar object, so if you wan't to change it after creation, then you have to do the following ...
public static Calendar changeLocale(Calendar cal, Locale loc) {
Calendar tmpCal = null;
if (cal != null) {
tmpCal = Calendar.getInstance(loc); // create a new Calendar object with the desired Locale
tmpCal.setTimeZone(cal.getTimeZone()); // copy the timezone ...
tmpCal.setTime(cal.getTime()); // ... and the time from the original Calendar to the new one
}
return tmpCal;
}
P.S.: Actually setTime() and setTimeInMillis() in Calendar do exactly the same ... here's an excerpt from the source of Calendar for a proof:
public final void setTime(Date date) {
setTimeInMillis(date.getTime());
}
Recent comments
1 year 45 weeks ago
3 years 14 weeks ago
3 years 14 weeks ago
3 years 16 weeks ago
3 years 17 weeks ago
3 years 24 weeks ago
3 years 24 weeks ago
3 years 24 weeks ago
3 years 24 weeks ago
3 years 24 weeks ago