| Author |
simpledateformat problem
|
John Schretz
Ranch Hand
Joined: Sep 10, 2008
Posts: 171
|
|
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
Joined: Nov 25, 2008
Posts: 66
|
|
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
Joined: Sep 10, 2008
Posts: 171
|
|
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?
|
 |
 |
|
|
subject: simpledateformat problem
|
|
|