I've got a bunch of dates in this String format:
String date = "Wed Sep 15 16:31:05 BST 2010";
and I'd like to convert it back to a date or calendar object. Before I go and reinvent the wheel, are there any easy ways of doing this, preferably present in the JDK?
Using SimpleDateFormat
String format = "EE MMM dd HH:mm:ss zz yyyy";
SimpleDateFormat sdf = new SimpleDateFormat(format, Locale.US);
Date result = sdf.parse(date);
Alternatively, as suggested by Jon Skeet, you can use JodaTime's DateTimeFormat
- the pattern should be the same. But it appears that the BDT/BST/BDST timezone aliases are not supported properly by JodaTime.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With