• 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
  • Devaka Cooray
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Jeanne Boyarsky
  • Tim Cooke
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
Bartenders:

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.
 
The harder I work, the luckier I get. -Sam Goldwyn So tiny. - this ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic