Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Parsing date/time with extra characters

807588Apr 26 2009 — edited Apr 29 2009
I have a date/time that I would like to parse to make more readable. The original format is like so:
2009-04-26T19:39:00-04:00
This is the date, then 24hr time which is separated by a T, then the time zone. In this case, the time zone is EDT, -4 hours. I have found that I can parse this with something like
formatter = new SimpleDateFormat ("yyy-MM-ddTHH:mm:ssZ");
This doesn't work, because of the T in the middle I assume. I have also tried
formatter = new SimpleDateFormat ("yyy-MM-dd" + "T" + "HH:mm:ssZ");
This doesn't work either. I get a compile error "Illegal patter character 'T'" for both of these. I am about to split the string into two sections, one with date before T, and one with time after T. Before I do this, I was just wondering if there is a cleaner way to do this, using some wildcard possibly?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 27 2009
Added on Apr 26 2009
8 comments
1,347 views