• Post Reply Bookmark Topic Watch Topic
  • New Topic

simpledateformat problem  RSS feed

 
John Schretz
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


I am having a problem formatting the above code

i need the date to look like this:
2009-05-22T00:16:51-04:00

But it comes out like this:
2009-05-22T00:16:51-0400

Is there a pattern in SDF to include the colon?

thanks
john
 
Birla Murugesan
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jhon,

There is no pattern available for output which you needed.

In your code :SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");

the capital Z denotes,for formatting you have been used RFC 822 time zone format.

so if go for the Pacific Standard Time ie use small letter 'z' instead of capital

SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssz");

you can get the output like this 2009-05-22T00:16:51GMT04:00

which is moreover what you expected.

Birla

 
John Schretz
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Birla Murugesan wrote:Jhon,

There is no pattern available for output which you needed.

In your code :SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");

the capital Z denotes,for formatting you have been used RFC 822 time zone format.

so if go for the Pacific Standard Time ie use small letter 'z' instead of capital

SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssz");

you can get the output like this 2009-05-22T00:16:51GMT04:00

which is moreover what you expected.

Birla




Unfortunately i need this exact date format 2009-05-22T00:16:51-04:00
amazon only accepts that format.
So i would have to manually add the colon?
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!