Skip to content
Advertisement

Tag: rfc3339

Output RFC 3339 Timestamp in Java

I want to output a timestamp with a PST offset (e.g., 2008-11-13T13:23:30-08:00). java.util.SimpleDateFormat does not seem to output timezone offsets in the hour:minute format, it excludes the colon. Is there a simple way to get that timestamp in Java? Also, SimpleDateFormat cannot properly parse the example above. It throws a ParseException. Answer Starting in Java 7, there’s the X pattern

Advertisement