Help coderanch get a
new server
by contributing to the fundraiser
  • 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to produce Oct 29, 2001 03:50:15 GMT

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Firends
Could anyone show me an example to produce the out put like the following Oct 29, 2001 03:50:15 GMT?
Thanks a lot
 
author
Posts: 3252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
String s = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, Locale.US).format(datetime);
Should come close. You can experiment with the format (MEDIUM, SHORT or LONG). If none of the formats is quite the way you want it, instantiate a SimpleDateFormat directly and use a format string (see the javadoc) - you'll lose the easy i18n though.
- Peter
 
Ranch Hand
Posts: 1514
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Date d = new Date()
SimpleDateFormat sdf = new SimpleDateFormat("MMMM dd, yyyy hh:mm:ss zzzz")
System.out.println(sdf.format(d))
You may need to modify it somewhat. Check the API for all the possible formats.

Bosun
 
lu v thuan
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank Peter den Haan and Bosun Bello for you explanation
 
Well THAT's new! Comfort me, reliable tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic