Only 44 hours left in the trailboss' kickstarter!

New rewards and stretch goals. CLICK HERE!



Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Output a date with timezone, in W3C datetime format?  RSS feed

 
Jimi Svedenholm
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

Unless I'm blind, I can't find an easy way to output a date in W3C datetime format, with timezon.

What I want is what W3C describes as YYYY-MM-DDThh:mm:ssTZD.
For example: 1997-07-16T19:20:30+01:00

http://www.w3.org/TR/NOTE-datetime

I looked at the SimpleDateFormat, but I can't find any way to get the timezone part with the colon between hour and minute. When I use the "Z" pattern it will not include the colon, and when I use the "z" pattern it prints "CET".

Any suggestions? I would really prefer not having to do string manipulations. And this should be doable using only standard java classes. Or?

Regards
/Jimi
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 15859
80
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've come across this problem also sometime. Unfortunately, there does not seem to be a way to make SimpleDateFormat format the timezone with the colon, so you'll have to do manually...:
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!