File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Date Format (URGENT) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Date Format (URGENT)" Watch "Date Format (URGENT)" New topic
Author

Date Format (URGENT)

Chhaya Dhanani
Ranch Hand

Joined: Apr 11, 2001
Posts: 70
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
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

Joined: Apr 11, 2001
Posts: 70
yup that is want i wanted!!
Thanks Mahesh..
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Date Format (URGENT)
 
Similar Threads
Date Format: How to know the Date in which format
Bean:write + formatting dates
so I have a sql date format I can't figure out
Sorting Date & Time
Needing help converting a date to useable format (2012-03-08T18:08:00Z)