The Artima Developer Community
Sponsored Link

Java Answers Forum
Date util function

1 reply on 1 page. Most recent reply: Oct 27, 2004 11:44 PM by Guillaume Taglang

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
samymohan

Posts: 2
Nickname: samymohan
Registered: Jan, 2004

Date util function Posted: Oct 26, 2004 3:24 AM
Reply to this message Reply
Advertisement
Hi,
How to format a date based on the date and format given
YYYY-MM-DDThh:mmTZD in java... please help me with some sample code.

For example like this method

public String getDateFormat(String sDate, String inputDateFormat,String outputDateFormat)



Regards
Samy


Guillaume Taglang

Posts: 18
Nickname: gouyou
Registered: Jul, 2003

Re: Date util function Posted: Oct 27, 2004 11:44 PM
Reply to this message Reply
Hi !

there is a good explanation how to do it in the javadoc of java.text.DateFormat and java.text.SimpleDateFormat.

And the code should be something like:
import java.text.SimpleDateFormat;
 
//...
 
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
 
Date myDate = sdf.parse("2004-10-28 08:30");
 
String formatedDate = sdf.format(myDate);


Cheers,
Guillaume

Flat View: This topic has 1 reply on 1 page
Topic: i don't understand  i ? Previous Topic   Next Topic Topic: Creating File In Java

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use