Re: Problem with NSTimestamp

"koteswararao mogili" <[email protected]>
Newsgroups gmane.comp.web.webobjects.eof,gmane.comp.web.webobjects.devel
Message-ID <[email protected]>
Hi,

The problem is resolved after doing the following modifications.

import java.text.*;
import com.webobjects.foundation.*;
import java.util.*;
public class DateTest {
	public static void main( String args[]) {
	   	NSTimeZone tz = NSTimeZone.localTimeZone();
       	NSTimestamp myNSTimestamp = new NSTimestamp(1900, 02,23, 13, 50,47, 
tz);
  	      GregorianCalendar cal = new GregorianCalendar();
		cal.clear();
		cal.setTime(myNSTimestamp);
		cal.set(GregorianCalendar.HOUR_OF_DAY, 13);
		cal.set(GregorianCalendar.MINUTE, 50);
		cal.set(GregorianCalendar.SECOND, 47);
		cal.setTimeZone(TimeZone.getDefault());
		NSTimestamp normalizedDate = new  NSTimestamp(cal.getTime());
      	SimpleDateFormat tErrorDateFormat = new SimpleDateFormat("HH");
		String strTmp = tErrorDateFormat.format(normalizedDate );
		System.out.println("New hour is ...."+new Integer(strTmp)+"    
"+normalizedDate );
	}
}


Thanks
Rao



>From: "koteswararao mogili" <[email protected]>
>To: [email protected], [email protected]
>Subject: Problem with NSTimestamp
>Date: Wed, 19 Feb 2003 00:20:06 +0530
>
>
>Hi,
>
>I have got a strange problem with NSTimestamp . When year is 1900 , the 
>hour is getting reduced by 1 after parsing with SimpleDateFormat. The 
>problem is not observed with Calendar.
>
>Please find the code below.
>
>Any suggestion or help is greatly appreciated..
>
>--Rao
>
>
>
>import java.text.*;
>
>import com.webobjects.foundation.*;
>
>import java.util.*;
>
>public class DateTest {
>
>public static void main( String args[]) {
>
>NSTimeZone tz = NSTimeZone.localTimeZone();
>
>NSTimestamp myNSTimestamp = new NSTimestamp(1900, 02,23, 10, 50,47, tz);
>
>/*Calendar rightNow = Calendar.getInstance();
>
>rightNow .set(1900, 02,23, 11, 50,47);*/
>
>SimpleDateFormat tErrorDateFormat = new SimpleDateFormat("HH");
>
>String strTmp = tErrorDateFormat.format(myNSTimestamp);
>
>System.out.println("Hour is ...."+new Integer(strTmp)+" "+myNSTimestamp);
>
>}
>
>}
>
>
>
>
>_________________________________________________________________
>MSN 8 with e-mail virus protection service: 2 months FREE* 
>http://join.msn.com/?page=features/virus
>
>_______________________________________________
>EOF mailing list
>[email protected]
>http://www.omnigroup.com/mailman/listinfo/eof


_________________________________________________________________
Tired of spam? Get advanced junk mail protection with MSN 8. 
http://join.msn.com/?page=features/junkmail
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.