List of usage examples for java.util GregorianCalendar getInstance
public static Calendar getInstance()
From source file:com.rogers.ute.creditservice.util.CreditServiceUtils.java
private static XMLGregorianCalendar asXMLGregorianCalendar(String date) { try {/*from w w w. ja v a 2s. c o m*/ XMLGregorianCalendar result = null; SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); GregorianCalendar gregorianCalendar = (GregorianCalendar) GregorianCalendar.getInstance(); /*Date date = simpleDateFormat.parse(date);*/ gregorianCalendar.setTime(simpleDateFormat.parse(date)); result = DatatypeFactory.newInstance().newXMLGregorianCalendar(gregorianCalendar); return result; } catch (Exception e) { e.printStackTrace(); } return null; }
From source file:Main.java
/** * Convert date from String to Xml GregorianCalendar in this 'MM/dd/yyyy hh:mm:ss' * @param s//from ww w. j a v a 2 s . c o m * @return * @throws DatatypeConfigurationException * @throws ParseException */ public static XMLGregorianCalendar stringToXMLGregorianCalendar(String s) throws DatatypeConfigurationException, ParseException { if (s != null && !(s.trim().length() < 1)) { XMLGregorianCalendar result = null; Date date; SimpleDateFormat simpleDateFormat; GregorianCalendar gregorianCalendar; simpleDateFormat = new SimpleDateFormat("MM/dd/yyyy hh:mm:ss"); date = simpleDateFormat.parse(s); gregorianCalendar = (GregorianCalendar) GregorianCalendar.getInstance(); gregorianCalendar.setTime(date); result = DatatypeFactory.newInstance().newXMLGregorianCalendar(gregorianCalendar); return result; } return null; }