My problem lies in parsing a custom date string in BlackBerry Java. Java SE provides the class SimpleDateFormat which has the ability to parse a String against a given pattern/format.
However, in BlackBerry the SimpleDateFormat class does not contain the method to parse, only format a date into the desired pattern.
I am aware of HttpDateFormatter which can parse a String, however, it is a strict parser that will only work with three date formats that HTTP has used in the past:
- Sun, 06 Nov 1994 08:49:37 GMT (RFC 822, updated by RFC 1123)
- Sunday, 06-Nov-94 08:49:37 GMT (RFC 850, obsoleted by RFC 1036)
- Sun Nov 6 08:49:37 1994 (ANSI C’s asctime() format)
I will be parsing date strings coming from the Twitter API in the format:
- “Mon Jun 27 19:32:19 +0000 2011”
Before going away and writing my own error prone date parse, is there any other routes I could investigate?
Regards,
Thomas Nadin
Yes, as of 7.1, there is no method to parse with a custom format in BB Java API. You should implement your own. I did it long ago using
Calendar, with the same format as the Java SE API.Before doing your own one, have a look at OpenSource projects like Joda, Guava or OpenJDK, maybe you can find some “inspiration” there.
Good luck.