Well aware of performance and thread issues with SimpleDateFormat
, I decided to go with FastDateFormat
, until I realized that FastDateFormat
At a best guess, it's to keep FastDateFormat... well... fast, by limiting it to display only.
Apache Commons DateUtils
has a parseDate
function, but that uses SimpleDateFormat
internally.
An alternative is to use the JodaTime library. It's a complete replacement for dealing with DateFormat
, Date
, and Calendar
objects.
JodaTime has a DateTimeFormatter that can be used to create DateTime objects (JodaTime's equivalent of Java's Date
objects) from strings.
An example of how to use it is like this:
String strInputDateTime = "2010-12-27"; // An example, this would really come from outside
DateTimeFormatter fmt = DateTimeFormat.forPattern("yyyy-MM-dd");
DateTime dt = fmt.parseDateTime(strInputDateTime);
I don't know if this is really any faster than SimpleDateFormat
, though.