File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Java in General
Generate date in 2011-04-26T16:52:57-05:00 format.
Joined: Nov 02, 2010
Aug 24, 2011 20:26:34
I am supposed to generate the current date in the below format and then set it onto an XML before consuming a web service.
By Using this code snippet below am able to generate the date without the 'T' and offset information.
sdfDate = new
Date now = new Date();
strDate = sdfDate.format(now);
I was able to get an output as
Can someone please let me know how to get the 'T' between the Date and Timestamp.
Thanks in Advance,
Joined: Jul 07, 2011
Aug 24, 2011 21:50:05
This means that your XML schema for that particular element is of type dataTime.
One option I would suggest is having compiled
classes of that XML schema. With this you can directly set that element using Calendar.getInstance();
It'll automatically reflect in this format.
Thanks and Regards,
Nilesh Sahni |
Joined: Oct 14, 2005
Aug 24, 2011 22:35:32
SimpleDateFormat sdfDate = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss-05.00");
Joined: Oct 13, 2005
Aug 25, 2011 01:34:08
Or you can use the %T?? tags in Formatter#format, PrintStream#printf, etc. For details, look in the documentation for
I agree. Here's the link:
subject: Generate date in 2011-04-26T16:52:57-05:00 format.
Convert String to Date format
convert now timestamp to 2011-05-02T19:50:42.868-04:00
How to change Date Format
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014