Re: NSTimestamp problem
Re: NSTimestamp problem
- Subject: Re: NSTimestamp problem
- From: Lachlan Deck <email@hidden>
- Date: Mon, 16 Jun 2008 07:55:42 +1000
On 15/06/2008, at 9:55 PM, 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);
TimeZone tz = TimeZone.getTimeZone( "Europe/London" );
Calendar cal = Calendar.getInstance( tz ); // cal instanceof
GregorianCalendar == true
// no need to setTime, it's already set to current time
// no need to get values. Use the calendar itself to adjust the month
cal.add( Calendar.MONTH, 1 );
TimeZone tz = TimeZone.getTimeZone( "Europe/London" );
Calendar cal = Calendar.getInstance( tz ); // cal instanceof
GregorianCalendar == true
// no need to setTime, it's already set to current time
// no need to get values. Use the calendar itself to adjust the month
cal.add( Calendar.MONTH, 1 );
SimpleDateFormat fm = new SimpleDateFormat("ddMMyyyy hh:mm:ss");
fm.setTimeZone( tz );
System.out.println( "New date:" + fm.format( cal.getTime() ) );
NSTimestamp correctedGMTDate = new NSTimestamp( cal.getTime() );
with regards,
--
Lachlan Deck
_______________________________________________
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