List of usage examples for javax.xml.datatype XMLGregorianCalendar setMillisecond
public abstract void setMillisecond(int millisecond);
From source file:org.talend.components.netsuite.client.model.search.SearchDateFieldAdapter.java
protected XMLGregorianCalendar convertDateTime(String input) { String valueToParse = input;/*www. j a v a 2 s. c o m*/ 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; }