• Post Reply Bookmark Topic Watch Topic
  • New Topic

xsd:date has trailing Z  RSS feed

 
Reshma Rangarajan
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Scenario: I am trying to get a date value from database and set it into a VO and then finally set it into an XMLschema field.

The first out stmt prints: 2009-01-06 which is fine.
The second out stmt prints: 2009-01-06Z which may be expected but i dont want the trailing Z to be there. Basically, this system will be called by an external system. so i dont want the xml date to have this trailing Z in place.

Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
Date date = resultSet.getDate("billDate", Calendar.getInstance());
cal.setTime(date);
billDetailVO.setLatestBillDate(cal);
System.out.println("Recent Bill Date is - " + billDetailVO.getLatestBillDate().toString());

billDetailT.setLatestBillDate(billDetailVO.getLatestBillDate());
System.out.println("Recent Bill Date is - " + billDetailT.getLatestBillDate().toString());


Can someone help me here please. I am new to this area. Let me know if i have missed some information.
Also, Please let me know if this question does not belong in this section.

Thanks,
Reshma
 
Naren Chivukula
Ranch Hand
Posts: 577
Java Notepad Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

The first out stmt prints: 2009-01-06 which is fine.
The second out stmt prints: 2009-01-06Z which may be expected but i dont want the trailing Z to be there.

I don't understand what these outputs you are talking about!

There are two options. You can use xsd:string for your VO xml schema instead of xsd:dateTime and upon truncating the date value just before Z, you can set it. Otherwise, use SimpleDateFormat API to format your date if you want to still use xsd:dateTime.
 
Reshma Rangarajan
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Naren, Thanks for replying.

I cannot use xsd:string for a date element. Its against the standards that my company follows

Second, I tried to do it using SimpleDateFormat. However, once the value is set into the XML calendar it was appending either the offset time (like -05:00) or the character 'Z'.

I modfied my code to set xmlDate into the response XML instead of java calendar. Now it is displaying as expected without the trailig 'Z' or the offset.

Thanks,
Reshma

 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!