“LOCALDATETIME TO XMLGREGRORIANIANCALENDAR” Code-Antworten

LOCALDATETIME TO XMLGREGRORIANIANCALENDAR

LocalDateTime localDatetime = LocalDateTime.now();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss");

String formattedDate = localDatetime.format(formatter);
XMLGregorianCalendar calendar = DatatypeFactory.newInstance().newXMLGregorianCalendar(formattedDate);
Gifted Grasshopper

LOCALDATETIME TO XMLGREGRORIANIANCALENDAR


LocalDateTime currentUTCTime = LocalDateTime.now(); // using system timezone
String iso = currentUTCTime.toString();
if (currentUTCTime.getSecond() == 0 && currentUTCTime.getNano() == 0) {
    iso += ":00"; // necessary hack because the second part is not optional in XML
}
XMLGregorianCalendar xml =
  DatatypeFactory.newInstance().newXMLGregorianCalendar(iso‌​);

Important Ibis

Ähnliche Antworten wie “LOCALDATETIME TO XMLGREGRORIANIANCALENDAR”

Fragen ähnlich wie “LOCALDATETIME TO XMLGREGRORIANIANCALENDAR”

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen