Thursday, July 07, 2005

Quick way to get a numerical date in Java

You can get the date and time in java using new Date(), which returns a Date object, but if you just want the date, in the format mm/dd/yyyy, you can do this:

DateFormat.getDateInstance(DateFormat.SHORT).format(new Date())

This returns a string based on the Date object returned by new Date().

No comments:

Labels

Blog Archive

Contributors