The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
September 2001

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

About time and date

Posted by Zane on September 17, 2001 at 10:42 PM

At first, you need to convert Date or time to String type by SimpleDateFormat class. e.g.

public static String getDateType(Date dateValue) {
String dateTempString=new String();
try{
SimpleDateFormat formatter = new SimpleDateFormat ("yyyy-MM-dd hh:mm:ss");
dateTempString = formatter.format(dateValue);

}catch(Exception e) { e.printStackTrace();}
return dateTempString;
}
The above function is convert Date to String and its format is
YYYY-MM-DDDD. Hope it would help you!


> I've some difficulties with handeling Date and time. I'm reading the date and Time seperately from a file as string. Now I need to calculate the difference between two dates (both are in string format). Same problem for the time. I need to calculate the difference between two times which are also in string format. I don't know how to do that.
> Can anybody help me?
> Thanks in advance.

> Suzon






Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us