Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_java_server thread: Session Data


Message #1 by "Ajay" <ajay@c...> on Tue, 26 Sep 2000 01:02:09 -0700
> hi may be problem with the servletrunner.try with JWS 2.0.
> try this code to get the system date.
> 
> Calendar myCal = Calendar.getInstance();
> 			String today = myCal.get( Calendar.YEAR) + "/";
> 			int myMonth = myCal.get( Calendar.MONTH) + 1;
> 			int myDay = myCal.get( Calendar.DATE);
> 			if( myMonth < 10 )
> 				today = today + "0" + myMonth + "/";
> 			else
> 				today = today + myMonth + "/";
> 			if( myDay < 10 )
> 				today = today + "0" + myDay;
> 			else
> 				today = today + myDay;

There's a somewhat easier way of doing exactly the same thing;
you only need the following two lines of code:

SimpleDateFormat df = new SimpleDateFormat("yyyy/MM/dd");
String today = df.format(new Date());

Cheers,

Dave.

-- 
David Long <davidl@w...>
Wrox Press - Programmer to Programmer(tm)
http://p2p.wrox.com/

  Return to Index