Take the 2-minute tour ×

Using Joda Time's pattern syntax below, this input string:

Sunday, January 09, 2011 6:15:00 PM

becomes this datetime:



String start = "Sunday, January 09, 2011 6:15:00 PM";

DateTimeFormatter parser1 = 

DateTime startTime = parser1.parseDateTime(start);

Is this format pattern incorrect? If not, what are the T and Z doing inside the DateTime output?

share|improve this question
add comment

2 Answers

up vote 6 down vote accepted

You've only shown the parsing code - not how you've converted the DateTime value back to a String.

I strongly suspect you're just calling toString(), which use the default DateTime ISO8601 format.

Don't forget that a DateTime value represents an instant in time in a particular time zone and calendar system - it has no concept of format patterns. The "T" and "Z" aren't in the DateTime value - they're just in the default representation of the value. It's like when you convert an int to a string - it happens to use decimal, but the number itself is just a number.

If you want to format a DateTime in a specific way, you should use

String text = formatter.print(startTime);
share|improve this answer
Thanks, Jon. Yes, I was calling toString as you guessed. –  Tree Jan 12 '11 at 23:49
add comment

T: Denotes start of "time part" of the string. Zone: 'Z' outputs offset. I suppose in thise case is GMT. Source:http://joda-time.sourceforge.net/apidocs/org/joda/time/format/DateTimeFormat.html

I always use this format string: yyyy-MM-dd'T'HH:mm:ss.SSSZ

And, yes, they are not incorrect, if they are present in your string.

share|improve this answer
Thanks cheekoo, I was missing the single quotes in the 'T'! –  Gaucho Jan 7 at 14:47
add comment

Your Answer


