Month and weekday names are shown in the language of the locale setting of
the Calendar
. The translations are acquired from
the standard Java locale data. By default, Calendar
uses the system default locale for its internal calendar, but you can
change it with setLocale(Locale locale)
. Setting
the locale will update also other location specific date and time
settings, such as the first day of the week, time zone, and time
format. However, time zone and time format can be overridden by settings
in the Calendar
.
For example, the following would set the language to US English:
cal.setLocale(Locale.US);
The locale defines the default time zone. You can change it with the
setTimeZone()
method, which takes a
java.util.TimeZone
object as its parameter. Setting
timezone to null will reset timezone to the locale default.
For example, the following would set the Finnish time zone, which is EET
cal.setTimeZone(TimeZone.getTimeZone("Europe/Helsinki"));
The time may be shown either in 24 or 12 hour format. The default format
is defined by the locale, but you can change it with the
setTimeFormat()
method. Giving a
null
setting will reset the time format to the locale
default.
cal.setTimeFormat(TimeFormat.Format12H);
You can change the format of the date captions in the week view with the
setWeeklyCaptionFormat(String dateFormatPattern)
method. The date format pattern should follow the format of the standard
Java java.text.SimpleDateFormat
class.
For example:
cal.setWeeklyCaptionFormat("dd-MM-yyyy");