Look this is not the fault of Calendar class. calling calendar.getTime() returns a Date instance. A date instance is not associated with any locale or time zone. Try displaying the calendar object itself and then see the output ...
Also to add, the java.text.DateFormat class is used to format a date instance according to a locale...
Himalay Majumdar
Ranch Hand
Joined: Sep 28, 2008
Posts: 324
posted
0
Right Ankit, we have DateFormat class to play with Locales, so my question is when do we need to use Locale reference in Calendar?
Byju Joy
Ranch Hand
Joined: Sep 06, 2005
Posts: 84
posted
0
Locale("th", "TH") --> you get a BuddhistCalendar.
and Locale("ja", "JP") --> you get a JapaneseImperialCalendar
All other Locales including Locale("hi", "IN") returns the default GregorianCalendar.
khaled Jamal
Ranch Hand
Joined: Feb 16, 2009
Posts: 64
posted
0
It is stated in k&B that Calendar.getInstance(Locale locale) is used for getting an object that lets you perform date and time calculations in a DIFFERENT locale
here is a sample code :
The output is :
Tue May 26 18:18:44 GMT 2009
26 maggio 2009
the funny about all this is when commenting Line 1 and uncommenting Line 2 the result is the same
Let us please know if Calendar.getInstance(Locale locale) has an effect
SCJP 6, SCBCD 5, SCWCD 5
Ruben Soto
Ranch Hand
Joined: Dec 16, 2008
Posts: 1032
posted
0
I think Byju already explained it.
All code in my posts, unless a source is explicitly mentioned, is my own.
khaled Jamal
Ranch Hand
Joined: Feb 16, 2009
Posts: 64
posted
0
I did not know what does Gregorian Calendar mean so I did not read the post carefully, after googling it I got it
The Gregorian Calendar is the internationally accepted civil calendar
Thanks
Himalay Majumdar
Ranch Hand
Joined: Sep 28, 2008
Posts: 324
posted
0
If I do the above in 1.5 I get the following output