dcsimg
Gregorian Calendar Usage in Thai Locale to get Current Year
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Amit_Kapur
Posted On:   Thursday, January 30, 2003 03:37 AM

In Thai Locale the Default year is 543 years ahead of the English Year. Thailand uses a Buddhist calendar whose year numbering begins the year Buddha died. A Thai date would be identical to a standard date except that the Thai year would be 543 greater than the standard year. Thus, December 31, 2001 would be expressed as December 31, 2544 in the Thai calendar. Now I have a machine where the default locale as well as Default Time zone is set to Thailand specific locale n timezone respectively. I am trying to get the date printed using Java Api for Gregorian Calendar GregorianCalendar gCal = new GregorianCalendar(TimeZone.getDefault(), Locale.getDefault()); System.out.println("YEA   More>>

In Thai Locale the Default year is 543 years ahead of the English Year.


Thailand uses a Buddhist calendar whose year numbering begins the year Buddha died. A Thai date would be identical to a standard date except that the Thai year would be 543 greater than the standard year. Thus, December 31, 2001 would be expressed as December 31, 2544 in the Thai calendar.


Now I have a machine where the default locale as well as Default Time zone is set to Thailand specific locale n timezone respectively. I am trying to get the date printed using Java Api for Gregorian Calendar

			
GregorianCalendar gCal = new GregorianCalendar(TimeZone.getDefault(), Locale.getDefault());
System.out.println("YEAR: " + gCal.get(Calendar.YEAR));



But this is giving me the result Year as 2003 although it should be 2546.

Kindly guide me on this


Regards

Amit    <<Less

Re: Gregorian Calendar Usage in Thai Locale to get Current Year

Posted By:   Amit_Kapur  
Posted On:   Thursday, April 24, 2003 09:55 PM

Following is the answer that I got from Nobert (java internationalization site) which correctly resolved my issue



Hi Amit,



The Thai Buddhist calendar has been implemented as subclass of GregorianCalendar that's not visible in the API. To get an instance of this class, call


Calendar.getInstance(new Locale("th", "TH"));


or, since your machine uses the Thai locale as its default,

Calendar.getInstance();


Thai support is implemented in releases 1.4 and higher.



Best regards,

Norbert

Re: Gregorian Calendar Usage in Thai Locale to get Current Year

Posted By:   Bahman_Barzideh  
Posted On:   Thursday, January 30, 2003 06:01 AM

Locale affects the way a date might be printed (its format for example). It will not affect the date calculation done by the calendar
classes. To do what you want, you will have to develop your own Calendar class, (BuddhistCalendar for example>. This is
next to impossible for most calendar's because of a bug in Calendar (see bug # 4209296 &
4638858) on SUN's bug parade database.



You may, however be in luck since according to your description you may be able to subclass GregorianCalendar and bypass the
above mentioned bug.
About | Sitemap | Contact