Example usage for org.joda.time Chronology withUTC

List of usage examples for org.joda.time Chronology withUTC

Introduction

In this page you can find the example usage for org.joda.time Chronology withUTC.

Prototype

public abstract Chronology withUTC();

Source Link

Document

Returns an instance of this Chronology that operates in the UTC time zone.

Usage

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/>/*from www. j a  v a  2  s .co  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:net.sourceforge.fenixedu.util.HourMinuteSecond.java

License:Open Source License

/**
 * Creates a new HourMinuteSecond instance with the specified chronology.
 * This instance is immutable and unaffected by this method call.
 * <p>/*from w w  w .j ava  2 s  .  c o m*/
 * This method retains the values of the fields, thus the result will typically refer to a different instant.
 * <p>
 * The time zone of the specified chronology is ignored, as HourMinuteSecond operates without a time zone.
 * 
 * @param newChronology
 *            the new chronology, null means ISO
 * @return a copy of this datetime with a different chronology
 * @throws IllegalArgumentException
 *             if the values are invalid for the new chronology
 */
public HourMinuteSecond withChronologyRetainFields(Chronology newChronology) {
    newChronology = DateTimeUtils.getChronology(newChronology);
    newChronology = newChronology.withUTC();
    if (newChronology == getChronology()) {
        return this;
    } else {
        HourMinuteSecond newHourMinuteSecond = new HourMinuteSecond(this, newChronology);
        newChronology.validate(newHourMinuteSecond, getValues());
        return newHourMinuteSecond;
    }
}