Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

LocalDateTime to XMLGregorianCalendar

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);
Comment

LocalDateTime to XMLGregorianCalendar


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‌​);

Comment

PREVIOUS NEXT
Code Example
Java :: javafx button with icon 
Java :: java double to string with comma 
Java :: java yesterday date 
Java :: java remove file extension from file name 
Java :: como utilizar random en java 
Java :: java how to calculate fps 
Java :: unit test java intellij 
Java :: android up navigation 
Java :: random number in range java 
Java :: for loop in multidimensional array java 
Java :: CellStyle change backgroung color java 
Java :: java how to create india currency 
Java :: java read last line of file 
Java :: create color object java 
Java :: java declare multilayred array values 
Java :: display default value of auto commit java 
Java :: how to download java on mint 
Java :: java get location of jar file 
Java :: java download file 
Java :: java swing get resource from image 
Java :: how to set audio of a java sound clip 
Java :: android studio print console 
Java :: jpa tree structure 
Java :: reverse recyclerview android 
Java :: sum and array list java 
Java :: java console colors 
Java :: how to iterate hashmap in java 
Java :: error: package androidx.multidex does not exist 
Java :: how to play an audio file in java 
Java :: convert date to calendar java 
ADD CONTENT
Topic
Content
Source link
Name
6+5 =