Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Parsing a date in Java?

Tags:

java

date

parsing

I have dates in text format of the form dd-mmm-yy or d-mmm-y, where months are abbreviations in letters (for example, 4-Nov-09 or 12-Dec-05, etc...) I would like to parse it to produce a java.util.Date object.

Could this be achieved by leveraging the java.text.DateFormat class? Or is there another easy way of doing this?

like image 503
David Menard Avatar asked Apr 14 '26 11:04

David Menard


1 Answers

You may need to use the SimpleDateFormat for parsing custom formats. This article explains the details of formatting.

"d-MMM-yyyy" corresponds to 4-Nov-2009
like image 121
Vincent Ramdhanie Avatar answered Apr 16 '26 23:04

Vincent Ramdhanie



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!