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 protected])
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/webobjects-dev/george%40boxofficetickets.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]