Archives: Java Date

Java – Convert java.util.Date to JodaTime

Make sure date isn’t null, though, otherwise it acts like new new DateTime()

Java – Date Validation with Regular Expression

Date Format (dd/mm/yyyy) Regular Expression Pattern


The above regular expression is used to validate the date format in “dd/mm/yyyy”, you can easy customize to suit your need. However, it’s a bit hard to validate the leap year, 30 or 31 days of a month, we may need basic logic as below.

Java – Convert Milliseconds to Date


current Date: Wed Feb 29 01:58:46 VET 2012
Milliseconds to Date: 29:02:12:01:58:46
Milliseconds to Date using Calendar:29:02:12:01:58:46
original Date: 29:02:12:01:58:46
copied Date: 29:02:12:01:58:46