Meaningless Drivel is fun!*
The moose likes Java in General and the fly likes Output a date with timezone, in W3C datetime format? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Output a date with timezone, in W3C datetime format?" Watch "Output a date with timezone, in W3C datetime format?" New topic
Author

Output a date with timezone, in W3C datetime format?

Jimi Svedenholm
Ranch Hand

Joined: May 19, 2001
Posts: 53
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
Saloon Keeper

Joined: Aug 16, 2005
Posts: 13884
    
  10

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...:


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Output a date with timezone, in W3C datetime format?
 
Similar Threads
String convert in to Date format
XSD date restriction
TimeZone formatation
java.util.Date in axis
date format conversion to MM/dd/yyyy hh:mm a