• 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

Date Format (URGENT)

 
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi all.
i want to dipslay the current date and time in the following format:'02/15/2002 11:41:39 PM'
i know using the java.util.Calender we can do this..
but i tried and cannot get it.
please let me know how i can get this format..
along with the AM/PM also..
a code snippet will be appreciated..
Thanx in advance.. and pls.. reply soon as this is a SOS!!!
Chhaya
 
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Try this code,
import java.util.SimpleTimeZone;
import java.util.Date;
import java.text.SimpleDateFormat;
public class datetest{
public static void main(String kk[]){
SimpleDateFormatformatter;
SimpleTimeZone stz = new SimpleTimeZone(+8*60*60*1000,"Asia/Singapore");
SimpleTimeZone.setDefault(stz);
formatter = new SimpleDateFormat("ddMMMyyyy hh:mm:ss a");
Date date = new Date();
String timeStamp = formatter.format(date).toString()+"\n";
System.out.println("Time is "+timeStamp);
}
}

Hope this is what u wanted

Mahesh
 
Chhaya Dhanani
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yup that is want i wanted!!
Thanks Mahesh..
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic