List of usage examples for org.joda.time MutableDateTime setZoneRetainFields
public void setZoneRetainFields(DateTimeZone newZone)
From source file:com.springsource.greenhouse.events.JdbcEventRepository.java
License:Apache License
private static DateTime adjustEventTimeToUTC(Timestamp timestamp, String eventTimeZone) { MutableDateTime mutableDateTime = new DateTime(timestamp).toMutableDateTime(); mutableDateTime.setZoneRetainFields(DateTimeZone.forID(eventTimeZone)); DateTime utcAdjustedDateTime = mutableDateTime.toDateTime().toDateTime(DateTimeZone.UTC); return utcAdjustedDateTime; }
From source file:org.talend.components.netsuite.avro.converter.XMLGregorianCalendarToDateTimeConverter.java
License:Open Source License
@Override public Object convertToAvro(XMLGregorianCalendar xts) { if (xts == null) { return null; }//w w w . ja v a 2s . co m MutableDateTime dateTime = new MutableDateTime(); try { dateTime.setYear(xts.getYear()); dateTime.setMonthOfYear(xts.getMonth()); dateTime.setDayOfMonth(xts.getDay()); dateTime.setHourOfDay(xts.getHour()); dateTime.setMinuteOfHour(xts.getMinute()); dateTime.setSecondOfMinute(xts.getSecond()); dateTime.setMillisOfSecond(xts.getMillisecond()); DateTimeZone tz = DateTimeZone.forOffsetMillis(xts.getTimezone() * 60000); if (tz != null) { dateTime.setZoneRetainFields(tz); } return Long.valueOf(dateTime.getMillis()); } catch (IllegalArgumentException e) { throw new ComponentException(e); } }