Hi, just when I think I understand how to format dates as strings.
Why is there a big difference between the date-time after formatting the date?
I'm running this on Solaris 6.
[code]
int ONE_HOUR = 1*1000*60*60;
SimpleTimeZone LocalTimeZone = new SimpleTimeZone(8*ONE_HOUR, "GMT+08:00");
TimeZone.setDefault(LocalTimeZone );
out.println("1. The time is: " + new Date()); // this displays the correct date time
while(someConditionIsTrue)
{
String sDate="";
Date rightNow = null;
SimpleDateFormat formatter=null;
formatter = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss"); // seems innocent enough...
rightNow = new Date(); // gives me the correct date-time
out.println("2. The time is: " + rightNow); //this works, shows correct local time
sDate = formatter.format(rightNow); // converting to string, this does not work, -15 hours difference
out.println("3. The current time: "+ sDate ); // bad date-time
[code]
I'm running this on Solaris 6