Question

I will work with third party API. They accept a date pattern like:

2012-02-15T17:34:37.937-0600

I know the pattern should be match like

yyyy-MM-ddTHH:mm:ss.s

But I am not sure how to represent the last "-0600" timezone? I think the standard timezone is "-06:00", anyone knows how to get rid of the ":" in the date pattern?

Thanks.

Was it helpful?

Solution

maybe you want "Z" ?

see http://docs.oracle.com/javase/6/docs/api/java/text/SimpleDateFormat.html:

  • 'z' gives you "Pacific Standard Time; PST; GMT-08:00"
  • 'Z' gives you "-0800"

This code:

final SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SZ");

produces:

2012-05-11T12:21:57.598+1000

OTHER TIPS

java.text.SimpleDateFormat should be very helpful for customize the string representation:

Z Time zone RFC 822 time zone -0800

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top