You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Align ISO timezone parsing in DateFormatter with Joda-Time / JSR-310 [SPR-14675] #19239
First, the javadoc example for DateTimeFormat.ISO.DATE_TIME is wrong; literal 'T' should be used between date and time. But even when this corrected it does not work:
Reason is the pattern specified in DateFormatter is wrong; for ISO, X should be used for timezone instead of Z (se javadoc for SimpleDateFormat). Correct pattern: yyyy-MM-dd'T'HH:mm:ss.SSSXXX
I see your point, and DateFormatter's parsing indeed differs from our Joda-Time and JSR-310 equivalents, with Joda-Time leniently accepting both "-05:00" and "-0500" but JSR-310 only accepting "-05:00" and DateFormatter only "-0500". While we certainly recommend the use of Joda-Time / JSR-310 date-time types, we should revisit the somewhat simplistic DateFormatter as well. I'm afraid we can only do that in 5.0 though since the existing format may be relied on in applications out there, not just for parsing but also for rendering... and subtle breakages might only get noticed at runtime.
So for the time being, specifying a custom pattern is the only way out if you can't use Joda-Time or JSR-310. I'll revise the javadoc with respect to the 'T' separator and will add a note on implementation-specific parsing differences.
Activity
spring-projects-issues commentedon Sep 9, 2016
Juergen Hoeller commented
I see your point, and
DateFormatter's parsing indeed differs from our Joda-Time and JSR-310 equivalents, with Joda-Time leniently accepting both "-05:00" and "-0500" but JSR-310 only accepting "-05:00" andDateFormatteronly "-0500". While we certainly recommend the use of Joda-Time / JSR-310 date-time types, we should revisit the somewhat simplisticDateFormatteras well. I'm afraid we can only do that in 5.0 though since the existing format may be relied on in applications out there, not just for parsing but also for rendering... and subtle breakages might only get noticed at runtime.So for the time being, specifying a custom pattern is the only way out if you can't use Joda-Time or JSR-310. I'll revise the javadoc with respect to the 'T' separator and will add a note on implementation-specific parsing differences.
spring-projects-issues commentedon Dec 26, 2016
Juergen Hoeller commented
As of 5.0 M4,
DateFormatter's ISO patterns use {XXX}} as discussed above, aligned with JSR-310 processing which it is typically auto-configured with.Note that
DefaultFormattingConversionServicestill prefers Joda-Time forDateandCalendarprocessing, if present at runtime.