Converting String to / from Date using Custom Formatting
In Java it is easy to convert a date as text / string to a Date object.
String to Date object
Date dateObj = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss").parse("05/18/05 18:15:10");
Date object to String
String dateStr = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss").format(dateObj);
No comments:
Post a Comment