java - Convert String of type "2015-23-07T00:00:00Z" to XMLGregorianCalender of format "07/23/2015T00:00:00Z" -
i calling web service accepts date xmlgregoriancalendar of format "07/23/2015t00:00:00z"
have database "2015-23-07t00:00:00z"
.
how convert string type of xmlgregoriancalender
of type
"mm/dd/yyyy't'hh:mm:ss.sss'z'"
since service hosted third party can't change schema , need implement conversion.
i tried this
date d = new date(); simpledateformat sdf1 = new simpledateformat("yyyy/mm/dd't'hh:mm:ss.sss'z'"); string formatteddate1 = sdf1.format(d); date date = sdf1.parse(formatteddate1); gregoriancalendar gregoriancalendar; xmlgregoriancalendar result = null; gregoriancalendar = (gregoriancalendar)gregoriancalendar.getinstance(); gregoriancalendar.settime(date); result = datatypefactory.newinstance().newxmlgregoriancalendar(gregoriancalendar);
java.text.dateformat outputformat =new java.text.simpledateformat("mm/dd/yyyy't'hh:mm:ss'z'"); java.text.dateformat outputformat1 =new java.text.simpledateformat("yyyy-dd-mm't'hh:mm:ss'z'"); system.out.println(outputformat.format(outputformat1.parse("2015-23-07t00:00:00z")));//07/23/2015t00:00:00z
Comments
Post a Comment