List of usage examples for javax.xml.datatype XMLGregorianCalendar setHour
public abstract void setHour(int hour);
From source file:org.talend.components.netsuite.client.model.search.SearchDateFieldAdapter.java
protected XMLGregorianCalendar convertDateTime(String input) { String valueToParse = input;/* www . ja va 2 s. c om*/ String dateTimeFormatPattern = dateFormatPattern + " " + timeFormatPattern; if (input.length() == dateFormatPattern.length()) { dateTimeFormatPattern = dateFormatPattern; } else if (input.length() == timeFormatPattern.length()) { DateTime dateTime = new DateTime(); DateTimeFormatter dateFormatter = DateTimeFormat.forPattern(dateFormatPattern); valueToParse = dateFormatter.print(dateTime) + " " + input; } DateTimeFormatter dateTimeFormatter = DateTimeFormat.forPattern(dateTimeFormatPattern); DateTime dateTime; try { dateTime = dateTimeFormatter.parseDateTime(valueToParse); } catch (IllegalArgumentException e) { throw new NetSuiteException(new NetSuiteErrorCode(NetSuiteErrorCode.CLIENT_ERROR), NetSuiteRuntimeI18n.MESSAGES.getMessage("error.searchDateField.invalidDateTimeFormat", valueToParse)); } XMLGregorianCalendar xts = datatypeFactory.newXMLGregorianCalendar(); xts.setYear(dateTime.getYear()); xts.setMonth(dateTime.getMonthOfYear()); xts.setDay(dateTime.getDayOfMonth()); xts.setHour(dateTime.getHourOfDay()); xts.setMinute(dateTime.getMinuteOfHour()); xts.setSecond(dateTime.getSecondOfMinute()); xts.setMillisecond(dateTime.getMillisOfSecond()); xts.setTimezone(dateTime.getZone().toTimeZone().getOffset(dateTime.getMillis()) / 60000); return xts; }
From source file:org.techytax.util.DateHelper.java
public static XMLGregorianCalendar getDateForXml(Date date) { XMLGregorianCalendar calendar = null; try {//ww w . ja v a 2 s . c o m calendar = DatatypeFactory.newInstance().newXMLGregorianCalendar(); } catch (DatatypeConfigurationException e) { e.printStackTrace(); } calendar.setDay(getDay(date)); calendar.setMonth(getMonth(date) + 1); calendar.setYear(getYear(date)); calendar.setHour(0); calendar.setMinute(0); calendar.setSecond(0); return calendar; }