Win a copy of Microservices Testing (Live Project) this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

Date conversion - Very urgent

 
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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){}
 
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
First, EaseUp.

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

Thanks and Rehards,
Sriram.
 
reply
    Bookmark Topic Watch Topic
  • New Topic