• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Timezone hell...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Timezone hell...


  • Subject: Re: Timezone hell...
  • From: George Domurot <email@hidden>
  • Date: Sat, 05 Mar 2011 16:57:11 -0800

Hi Pascal,

I think the problem is how you're creating the NSTimestamp.  There shouldn't be any need to pass the timezone in, unless the mills are offset for some reason.  (Calendar.getTimeInMillis = NSTimestamp.getTime)

java.util.Calendar calendarNow = GregorianCalendar.getInstance(TimeZone.getTimeZone("America/Montreal"));
NSTimestamp timestampNow = new NSTimestamp();
NSTimestamp timestampForCalendearNow = new NSTimestamp(calendarNow.getTimeInMillis());

NSLog.out.appendln(calendarNow.getTimeInMillis());
NSLog.out.appendln(timestampNow.getTime());
NSLog.out.appendln(timestampForCalendearNow.getTime());

##output##

Mar 05 16:55:45 TestTime[56087] INFO  NSLog  - 1299372945861
Mar 05 16:55:45 TestTime[56087] INFO  NSLog  - 1299372945861
Mar 05 16:55:45 TestTime[56087] INFO  NSLog  - 1299372945861

-G


On Mar 5, 2011, at 4:24 PM, Pascal Robert wrote:

> Ok, I'm loss here:
>
>    java.util.Calendar now = GregorianCalendar.getInstance(TimeZone.getTimeZone("America/Montreal"));
>    NSTimestamp nst = new NSTimestamp(now.getTimeInMillis(), now.getTimeZone());
>    NSLog.out.appendln(nst);
>    NSLog.out.appendln(nst.getTime());
>    NSLog.out.appendln(nst.timeZone().getID());
>
> So, the time coming from java.util.Calendar is 19:16:19, in America/Montreal. That's ok. The problem is with NSTimestamp:
>
>    mars 05 19:16:19 ShareCalPrototype[53879] INFO  NSLog  - 2011-03-05 19:16:19 Etc/GMT
>    mars 05 19:16:19 ShareCalPrototype[53879] INFO  NSLog  - 1299352579671
>    mars 05 19:16:19 ShareCalPrototype[53879] INFO  NSLog  - Etc/GMT
>
> So the time is 19:16:19 in the NSTimestamp, but the timezone is GMT, so when I display it in America/Montreal, it shows 14:16:19 :-/
>
> According to the JavaDoc:
>
>  NSTimestamp does not maintain time zone information. All NSTimestamps are millisecond offsets since the reference date in the reference time zone. This method assumes time is a time from the tz time zone, and converts time into a time appropriate for NSTimestamp to handle.
>
> Ok, so I guess it's normal that the timezone is GMT, but it should add 5 hours to the time? _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Webobjects-dev mailing list      (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Timezone hell... (From: Pascal Robert <email@hidden>)

  • Prev by Date: Timezone hell...
  • Next by Date: Re: ERModernLook is not the default skin for new D2W project!
  • Previous by thread: Timezone hell...
  • Next by thread: Dependent popup in D2W
  • Index(es):
    • Date
    • Thread