views:

212

answers:

1

I'm converting from a local time zone to UTC so when we convert

2010-01-03T11:15:58.840+11:00 => Sun, 03 Jan 2010 24:15:58 UTC

This is technically correct but I'm having problems with the 24 hour formatting as it does. I have some BlackBerry J2ME code which is having problems parsing this date-time String using HttpDateParser.

new Long(HttpDateParser.parse("Sun, 03 Jan 2010 24:15:58 UTC")

Shouldn't this really be "Sun, 03 Jan 2010 0:15:58 UTC"? If I pass in this new date String it will parse just fine. I'd rather not do a nasty "search and replace", but fix the problem at the server.

Question: Is it possible to stop Joda from displaying times as "24:xx:xx" and instead format as "0:xx:xx"?

Edit: I'm formatting the output date as

public static final SimpleDateFormat DATE_FMT =
      new SimpleDateFormat("EEE, dd MMM yyyy kk:mm:ss zzz");
+2  A: 

Try this format (HH instead of kk):

public static final SimpleDateFormat DATE_FMT =
  new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz");

That information is in the SimpleDateFormat JavaDoc.

Joda’s formatter has similar pattern format.

Ivan Dubrov
kk ty. You are exactly right. It's so simple.
Ben Clark-Robinson