dcsimg
Java calendar class returns differnt value than server date function
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anil_Kumar
Posted On:   Monday, May 24, 2004 08:39 PM

hi I had a java application (EJB) running in a sun sparc maching. The application is in jboss3.2.3 app server. While execution, the calendar date returns the value greater than the server date format. I had created a sample java class as below public class calendarTest { public static void main(String arg[]){ SimpleDateFormat dtFormatter = new SimpleDateFormat("dd/MM/yyyy"); Calendar c= Calendar.getInstance(); String times=dtFormatter.format(c.getTime()); System.out.println("c.getTime() ==> "+ c.getTime() ); System.out.println("times ==> "+ times );    More>>

hi


I had a java application (EJB) running in a sun sparc maching. The application is in jboss3.2.3 app server.



While execution, the calendar date returns the value greater than the server date format.

I had created a sample java class as below



public class calendarTest {

public static void main(String arg[]){

SimpleDateFormat dtFormatter = new SimpleDateFormat("dd/MM/yyyy");

Calendar c= Calendar.getInstance();

String times=dtFormatter.format(c.getTime());

System.out.println("c.getTime() ==> "+ c.getTime() );

System.out.println("times ==> "+ times );

}

}



While running the above application,

$ java calendarTest

c.getTime() ==> Tue May 25 02:28:29 GMT+07:00 2004

times ==> 25/05/2004

$

is obtained.

And while executing date function in unix



$ date

Mon May 24 12:28:37 GMT 2004

$

is obtained.




The actual date is May 24(obtained in date function ).



Can any one help me, why this is happening and any correction to be done in SUN os to correct this.



thanks

Anil

   <<Less

Re: Java calendar class returns differnt value than server date function

Posted By:   joe_user  
Posted On:   Monday, May 24, 2004 09:48 PM

This is probably a dumb question, but here goes: are you certain the date call on unix is executed on the same machine your java program is running on? I notice that the first one reports approx. 9.30AM, the second 12.30PM, or 02:28GMT vs. 12.28GMT. Assuming you ran the two tests at the same time, something is not right.
About | Sitemap | Contact