• 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
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic