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.

SimpleDateFormat to use a different timezone?

different timezone
0
10 Posted

SimpleDateFormat to use a different timezone?

0
10

[*] The following code sets the timezone of a DateFormat to the current default. DateFormat df = DateFormat.getDateInstance(); df.setTimeZone(TimeZone.getDefault()); or to set it to a timezone of your chioce. df.setTimeZone(TimeZone.getTimeZone( “MST” ) ) // Mtn Time, Denver USA 33. (Sect. 9) What century is assumed when I use a two digit year in a SimpleDateFormat string? [*]In JDK 1.1, the default start for the century used by SimpleDateFormat for 2 digit years is 80 years before the current date. This means that in 1998: 1 = 2001, 2 = 2002, … 17 = 2017, 18 = 2018, 19 = 1919, 20 = 1920, … 98 = 1998, 99 = 1999, In JDK 1.2 you can change this “default century start date” with the method set2DigitYearStart( Date) and get its current value with the method get2DigitYearStart(). One thing to note is that since set2DigitYearStart takes a date not a year, you can have your default century begin at any day or hour. When running under JDK 1.1, it is probably best to avoid two-digit year fi

Related Questions

What is your question?

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