time zone. Europe / London is currently in BST which is 1 hour ahead of GMT.

i think if you also print out GregorianCalendar.HOUR_OF_DAY you'll find it's = 11, not 12, because it's using GMT.

depending on what you are trying to achieve you may find it easier to work everything at GMT rather than local timezone, then convert to local (if required) when displaying to user. You can do so by sticking this in your application constructor:

NSTimeZone.setDefaultTimeZone(NSTimeZone.getGMT());

Simon



On 15 Jun 2008, at 12:55, Gino Pacitti wrote:

Does anyone have a link to solution to hour of day being incorrect?


NSTimeZone tz = NSTimeZone.timeZoneWithName("Europe/London", true);
      java.util.GregorianCalendar calendar = new GregorianCalendar();
      calendar.setTime(new NSTimestamp());
       int year = calendar.get(GregorianCalendar.YEAR);
       int dayOfMonth = calendar.get(GregorianCalendar.DAY_OF_MONTH);
       int month = calendar.get(GregorianCalendar.MONTH);
       int hour = calendar.get(GregorianCalendar.HOUR_OF_DAY);
       int minute = calendar.get(GregorianCalendar.MINUTE);
       int second = calendar.get(GregorianCalendar.SECOND);

NSTimestamp correctedDate = new NSTimestamp(year, ++month, dayOfMonth, hour, minute, second, tz);

Current time
2008-06-15 12:51:15 Etc/GMT

      System.out.println("Time Stamp Date"  + correctedDate);


Time reported
2008-06-15 11:51:15 Etc/GMT

Why do I loose the hour?

WO 5.3.* OSX 10.4.11 Java 1.5

Any help appreciated..

Gino
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/simon_mclean%40mac.com

This email sent to [EMAIL PROTECTED]

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to