class Calendar TimeZone Locale


Understanding Time Zone

The earth is demarcated into 24 regions and each region is given a name like India Time Zone (I) and Christmas Island Time (CXT) etc. Each region constitutes two longitudes separated by 15 degrees and is known as local time for that region. The local time will be the same for the whole region. The time difference with the adjacent regions is 1 hour. The local time is an offset from the Greenwich Mean Time (also known as UTC, Coordinated Universal Time).

Perception of Locale

A locale gives the particulars of a locality like language, cultural habits, currency and the country etc. An operating system comes by default loaded with the locale as Locale Identifier (LCID) like Locale.bg for Bulgaria etc.

Using locale in Java (class Calendar TimeZone Locale)

Suppose we would like to know about Bulgaria locale. Following is the snippet of code.

SimpleDateFormat format = new SimpleDateFormat("dd-MMM-yyyy HH:mm", Locale.bg);
Date date = format.parse("12-Jan-2011 10:45");
System.out.println(date);

The above statement prints the Bulgarian date.

Leave a Comment

Your email address will not be published.