I want to convert this form value into the xsd datetime format yyyy-MM-ddThh:mm:ss.
How can I do this?
I have been using the following code, but this just deals with today's date. I need to alter it so that it can deal with the value from the popup calendar:
Calendar calendar = Calendar.getInstance(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss"); StringBuffer sb = new StringBuffer( sdf.format(calendar.getTime()) );
Hi Rob, I am aware of that. That's why I'm wondering is there a way to convert the string value into some java calendar instance which can then be parsed?
Well, there is no direct way of parsing Calendar objects. Instead, you parse Date objects.
When you called calendar.getTime(), that returned a Date object. I basically did the same except without using a Calendar object, which is unnecessary for what you want.
If you do want a Calendar object, create one with Calendar.getInstance(), then use setTime() to set the Date object you got from parsing.