
net.time4j.clock.AbstractClock Maven / Gradle / Ivy
/*
* -----------------------------------------------------------------------
* Copyright © 2013-2015 Meno Hochschild,
* -----------------------------------------------------------------------
* This file (AbstractClock.java) is part of project Time4J.
*
* Time4J is free software: You can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 2.1 of the License, or
* (at your option) any later version.
*
* Time4J is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Time4J. If not, see .
* -----------------------------------------------------------------------
*/
package net.time4j.clock;
import net.time4j.Moment;
import net.time4j.ZonalClock;
import net.time4j.base.TimeSource;
import net.time4j.tz.TZID;
import net.time4j.tz.Timezone;
/**
* Abstract base clock implementation which allows local views within
* any timezone.
*
* @author Meno Hochschild
* @since 2.1
*/
/*[deutsch]
* Abstrakte Basisimplementierung, die eine lokale Sicht innerhalb einer
* Zeitzone bietet.
*
* @author Meno Hochschild
* @since 2.1
*/
public abstract class AbstractClock
implements TimeSource {
//~ Methoden ----------------------------------------------------------
/**
* Creates a local clock in platform timezone.
*
* @return local clock in system timezone (using the platform timezone data)
* @since 3.3/4.2
* @see java.util.TimeZone
* @see Timezone#ofSystem()
*/
/*[deutsch]
* Erzeugt eine lokale Uhr in der Plattform-Zeitzone.
*
* @return local clock in system timezone (using the platform timezone data)
* @since 3.3/4.2
* @see java.util.TimeZone
* @see Timezone#ofSystem()
*/
public ZonalClock inPlatformView() {
String tzid = "java.util.TimeZone~" + Timezone.ofSystem().getID().canonical();
return new ZonalClock(this, tzid);
}
/**
* Creates a local clock in system timezone.
*
* @return local clock in system timezone (using the best available timezone data)
* @since 2.1
* @see Timezone#ofSystem()
*/
/*[deutsch]
* Erzeugt eine lokale Uhr in der System-Zeitzone.
*
* @return local clock in system timezone (using the best available timezone data)
* @since 2.1
* @see Timezone#ofSystem()
*/
public ZonalClock inLocalView() {
return new ZonalClock(this, Timezone.ofSystem().getID());
}
/**
* Creates a local clock in given timezone.
*
* @param tzid timezone id
* @return local clock in given timezone
* @throws IllegalArgumentException if given timezone cannot be loaded
* @since 2.1
*/
/*[deutsch]
* Erzeugt eine lokale Uhr in der angegebenen Zeitzone.
*
* @param tzid timezone id
* @return local clock in given timezone
* @throws IllegalArgumentException if given timezone cannot be loaded
* @since 2.1
*/
public ZonalClock inZonalView(TZID tzid) {
return new ZonalClock(this, tzid);
}
/**
* Creates a local clock in given timezone.
*
* @param tzid timezone id
* @return local clock in given timezone
* @throws IllegalArgumentException if given timezone cannot be loaded
* @since 2.1
*/
/*[deutsch]
* Erzeugt eine lokale Uhr in der angegebenen Zeitzone.
*
* @param tzid timezone id
* @return local clock in given timezone
* @throws IllegalArgumentException if given timezone cannot be loaded
* @since 2.1
*/
public ZonalClock inZonalView(String tzid) {
return new ZonalClock(this, tzid);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy