• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

Date Format (URGENT)  RSS feed

 
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • Quote
  • Report post to moderator
yup that is want i wanted!!
Thanks Mahesh..
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!