List of usage examples for org.joda.time Chronology getZone
public abstract DateTimeZone getZone();
From source file:ch.oakmountain.tpa.solver.PeriodicalTimeFrame.java
License:Apache License
/** * Constructs an instance set to the local time defined by the specified * instant evaluated using the specified chronology. * <p/>/* ww w . ja v a 2 s .c o m*/ * If the chronology is null, ISO chronology in the default zone is used. * Once the constructor is completed, the zone is no longer used. * * @param instant the milliseconds from 1970-01-01T00:00:00Z * @param chronology the chronology, null means ISOChronology in default zone */ public PeriodicalTimeFrame(long instant, Chronology chronology) { chronology = DateTimeUtils.getChronology(chronology); long localMillis = chronology.getZone().getMillisKeepLocal(DateTimeZone.UTC, instant); iLocalMillis = localMillis; iChronology = chronology.withUTC(); }
From source file:com.googlecode.icegem.serialization.serializers.JodaTimeDataSerializer.java
License:Open Source License
@Override public boolean toData(Object o, DataOutput dataOutput) throws IOException { if (o instanceof DateTime) { DateTime dt = (DateTime) o;//from w w w . j av a 2s.c om dataOutput.writeLong(dt.getMillis()); Chronology chronology = dt.getChronology(); boolean customChronology = false; if (!chronology.getClass().getName().equals(ISOChronology.class.getName())) { customChronology = true; } byte flags = 0; boolean customTimeZone = true; String timeZoneId = chronology.getZone().getID(); for (byte i = 0; i < TIMEZONE_IDS.length; i++) { if (timeZoneId.equals(TIMEZONE_IDS[i])) { flags = i; customTimeZone = false; break; } } if (customTimeZone) { flags = CUSTOM_TZ_ID; } flags |= customChronology ? (1 << 7) : 0; dataOutput.write(flags); if (customChronology) { dataOutput.writeUTF(chronology.getClass().getName()); } if (customTimeZone) { dataOutput.writeUTF(chronology.getZone().getID()); } return true; } return false; }