3

I have dates like -

15-JUL-10 00:00:00

12-AUG-10 23:59:59

24-SEP-10 18:13:18

How do I easily parse these sort of dates and assign to a Date object?

2 Answers2

2

Using java.text.SimpleDateFormat:

DateFormat df = new SimpleDateFormat("dd-MMM-yy HH:mm:ss");
df.parse(dateString);
Bozho
  • 588,226
  • 146
  • 1,060
  • 1,140
1

Use SimpleDateFormat.

DateFormat fmt = new SimpleDateFormat("dd-MMM-yy HH:mm:ss");
Date date = fmt.parse("15-JUL-10 00:00:00");
Mark Peters
  • 80,126
  • 17
  • 159
  • 190