java - Is there a way to Parse NULL value to XMLGregorian Date format? -
i getting response of capital (null) external system need convert xmlgregorian date format & set xmlgregorian object. this? following code snippet trying parse with:
public static xmlgregoriancalendar toxmlgregoriancalendarwithtimezone(string date) throws parseexception, datatypeconfigurationexception { string format = "dd/mm/yyyy hh:mm:ss z"; gregoriancalendar cal = new gregoriancalendar(); simpledateformat formatter = new simpledateformat(format); formatter.settimezone(cal.gettimezone()); cal.settime(formatter.parse(date)); xmlgregoriancalendar calendar = datatypefactory.newinstance().newxmlgregoriancalendar(cal.get(calendar.year), cal.get(calendar.month) + 1, cal.get(calendar.day_of_month), cal.get(calendar.hour_of_day), cal.get(calendar.minute), cal.get(calendar.second), datatypeconstants.field_undefined, cal.get(calendar.zone_offset)); return calendar; }
my soapui request payload:
<soapenv:header/> <soapenv:body> <usagehis> <versionid>1</versionid> <deviceid>1234</deviceid> <startdateandtime>2016-09-09 10:10:10</startdateandtime> <enddateandtime>2016-09-09 10:10:10</enddateandtime> <startrange>1</startrange> <endrange>12</endrange> <transactiontype>cdr</transactiontype> </usagehis> </soapenv:body>
my soapui response:
`
<env:body> <usagehisresponse> <status> <statuscode>success</statuscode> <errorcode>null</errorcode> <errordescription>null</errordescription> <totalnoofrecords>1</totalnoofrecords> </status> records> <cdr> <starttime>09/09/2016 00:00:00 cdt</starttime> <downloadvolume>20</downloadvolume> <uploadvolume>10</uploadvolume> <uservolume>0</uservolume> <devicevolume>0</devicevolume> </cdr> </records> <usagehisresponse> </env:body>
`
something can solve problem:
if (tobeparsed.equals("null")) { date = null; } else { // try parse tobeparsed date = .... }
Comments
Post a Comment