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
Mahesh Mamani
Ranch Hand
Joined: Jun 25, 2001
Posts: 110
posted
0
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); } }