Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

Do all the standard objects use the same default timezone?

0
Posted

Do all the standard objects use the same default timezone?

0

[*] Not until JDK 1.2. In JDK 1.1, Date.toString() and Calendar used the value of TimeZone.getDefault() which could often be undefined (see the previous question). In JDK 1.1, The Calendar in a SimpleDateFormat was set to the 1st timezone resource for the locale (for the US this is PST). System.out.println( “Date format TZ = ” + TimeZone.getDefault().getID() ); sdf = DateFormat.getDateTimeInstance( DateFormat.LONG, DateFormat.LONG ); System.out.println( “Date format TZ = ” + sdf.getTimeZone().getID() ); Calendar cal = Calendar.getInstance(); System.out.println( “Calendar TZ = ” + cal.getTimeZone().getID() ); When run on a system running JDK 1.1.6, NOT in the North American Pacific Time nor in the GMT timezone results in: Timezone default = GMT Date format TZ = PST Calendar TZ = GMT This example shows two bugs, the value of user.timezone is undefined, so its defaulting to GMT (see discussion of TimeZone.getDefault()) and it shows that the DateFormat depends on the 1st locale entry which

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.