• Post Reply Bookmark Topic Watch Topic
  • New Topic

Date conversion - Very urgent  RSS feed

 
Sriram Sharma
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a date in the format "yyyy-mm-dd hh:mm:ss.s". This is a timestamp date format
I need to convert this date to the format "dd-mm-yyyy hhmm".
Can somebody help me out on this? This is very urgent.

Thanks in advance.

Regards,
Sriram.
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try{System.out.println(new java.text.SimpleDateFormat("dd-MM-yyyy hhmm").format(new java.text.SimpleDateFormat("yyyy-MM-dd hh:mm:ss.s").parse("2006-04-12 10:11:12.13")));}catch(Exception e){}
 
naveen gupta
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have done something similar to it. Follow it

*****

SimpleDateFormat dateFormatter = new SimpleDateFormat("dd MMM yyyy");
Date date = dateFormatter.parse("21 JAN 2004");
GregorianCalendar cal = new GregorianCalendar();
cal.setTime(date);
String rqlDate = cal.get(Calendar.YEAR)+"-"+((cal.get(Calendar.MONTH))+1)+"-"+cal.get(Calendar.DATE);

******

the rqlDate value will be "2004-01-21"

Browse the above classes GregorianCalendar , Date for more information
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First, EaseUp.

Look at java.text.DateFormat. Should give you an idea.
 
Sriram Sharma
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am obliged. :-)
Thanks everybody for your contribution in my new learning.

Thanks and Rehards,
Sriram.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!