Package org.openjdk.jmc.common.unit
Class TimestampKind
- java.lang.Object
-
- org.openjdk.jmc.common.unit.ContentType<IQuantity>
-
- org.openjdk.jmc.common.unit.KindOfQuantity<TimestampUnit>
-
- org.openjdk.jmc.common.unit.TimestampKind
-
- All Implemented Interfaces:
IDescribable,IType<IQuantity>,IConstraint<IQuantity>,IPersister<IQuantity>
class TimestampKind extends KindOfQuantity<TimestampUnit>
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classTimestampKind.FractionFormatterprivate static classTimestampKind.LegacyAndFractionFormatterprivate static classTimestampKind.LegacyFormatter-
Nested classes/interfaces inherited from class org.openjdk.jmc.common.unit.KindOfQuantity
KindOfQuantity.ExactFormatter<U extends TypedUnit<U>>, KindOfQuantity.VerboseFormatter<U extends TypedUnit<U>>
-
-
Field Summary
-
Fields inherited from class org.openjdk.jmc.common.unit.ContentType
m_identifier
-
-
Constructor Summary
Constructors Modifier Constructor Description privateTimestampKind()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static TimestampKindbuildContentType(LinearKindOfQuantity timespan)(package private) static java.text.DateFormatgetDateTimeFormatter()Only for formatting, not parsing!TimestampUnitgetDefaultUnit()KindOfQuantity<LinearUnit>getDeltaKind()IFormatter<IQuantity>getFormatterResolving(IRange<IQuantity> range)Get a formatter with sufficient resolution to produce unique strings for both ends ofrange, and consecutive equally spaced quantities.TimestampUnitgetLargestExactUnit(IQuantity value)Get the largest unit, if any, in which this quantity can be expressed exactly, typically with an integer.TimestampUnitgetPreferredUnit(IQuantity value, double minNumericalValue, double maxNumericalValue)ITypedQuantity<TimestampUnit>parseInteractive(java.lang.String interactiveQuantity)Parse an interactive string.ITypedQuantity<TimestampUnit>parsePersisted(java.lang.String persistedQuantity)Parse a persisted string.private static java.text.DateFormatpatchYear(java.text.DateFormat df)-
Methods inherited from class org.openjdk.jmc.common.unit.KindOfQuantity
addUnit, combine, format, getAccessor, getAccessorKeys, getAllUnits, getAttributes, getCommonUnits, getFirstBucket, getFirstBucket, getPersister, getRangeFormatter, getUnit, interactiveFormat, persistableString, resolveLocalizedName, resolveLocalizedSymbol, validate
-
Methods inherited from class org.openjdk.jmc.common.unit.ContentType
addFormatter, getDefaultFormatter, getDescription, getFormatter, getFormatters, getIdentifier, getName, hasAttribute, lookupNameFor, toString
-
-
-
-
Field Detail
-
NUMBER_UNIT_PATTERN
private static final java.util.regex.Pattern NUMBER_UNIT_PATTERN
-
DATE_TIME_FORMATTER_HOLDER
private static final FormatThreadLocal<java.text.DateFormat> DATE_TIME_FORMATTER_HOLDER
-
NANOS_UNIT
static TimestampUnit NANOS_UNIT
-
MICROS_UNIT
static TimestampUnit MICROS_UNIT
-
MILLIS_UNIT
static TimestampUnit MILLIS_UNIT
-
SECONDS_UNIT
static TimestampUnit SECONDS_UNIT
-
INSTANCE
static TimestampKind INSTANCE
-
YEAR_TO_DAY_FORMATTER
private static IFormatter<IQuantity> YEAR_TO_DAY_FORMATTER
-
YEAR_TO_SECONDS_FORMATTER
private static IFormatter<IQuantity> YEAR_TO_SECONDS_FORMATTER
-
YEAR_TO_MILLIS_FORMATTER
private static IFormatter<IQuantity> YEAR_TO_MILLIS_FORMATTER
-
YEAR_TO_MICROS_FORMATTER
private static IFormatter<IQuantity> YEAR_TO_MICROS_FORMATTER
-
YEAR_TO_NANOS_FORMATTER
private static IFormatter<IQuantity> YEAR_TO_NANOS_FORMATTER
-
HOUR_TO_SECONDS_FORMATTER
private static IFormatter<IQuantity> HOUR_TO_SECONDS_FORMATTER
-
HOUR_TO_MILLIS_FORMATTER
private static IFormatter<IQuantity> HOUR_TO_MILLIS_FORMATTER
-
HOUR_TO_MICROS_FORMATTER
private static IFormatter<IQuantity> HOUR_TO_MICROS_FORMATTER
-
HOUR_TO_NANOS_FORMATTER
private static IFormatter<IQuantity> HOUR_TO_NANOS_FORMATTER
-
MILLIS_FORMATTER
private static IFormatter<IQuantity> MILLIS_FORMATTER
-
MICROS_FORMATTER
private static IFormatter<IQuantity> MICROS_FORMATTER
-
NANOS_FORMATTER
private static IFormatter<IQuantity> NANOS_FORMATTER
-
-
Method Detail
-
patchYear
private static java.text.DateFormat patchYear(java.text.DateFormat df)
-
getDateTimeFormatter
static java.text.DateFormat getDateTimeFormatter()
Only for formatting, not parsing!
-
buildContentType
public static TimestampKind buildContentType(LinearKindOfQuantity timespan)
-
getPreferredUnit
public TimestampUnit getPreferredUnit(IQuantity value, double minNumericalValue, double maxNumericalValue)
- Specified by:
getPreferredUnitin classKindOfQuantity<TimestampUnit>
-
getLargestExactUnit
public TimestampUnit getLargestExactUnit(IQuantity value)
Description copied from class:KindOfQuantityGet the largest unit, if any, in which this quantity can be expressed exactly, typically with an integer. If the quantity has zero magnitude (),quantity.doubleValue()== 0.0quantity.getUnit()will be returned. Thus, if you want to find out a maximum common unit for a set of quantities (not recommended), only use the non-zero quantities.Note that this may be a fairly expensive operation, and isn't intended to be used excessively. The only valid use case is for guessing the original unit in which a quantity was expressed, after it has been stored or transmitted using a legacy mechanism with a fixed unit.
- Specified by:
getLargestExactUnitin classKindOfQuantity<TimestampUnit>- Returns:
- a unit or
null
-
getFormatterResolving
public IFormatter<IQuantity> getFormatterResolving(IRange<IQuantity> range)
Description copied from class:KindOfQuantityGet a formatter with sufficient resolution to produce unique strings for both ends ofrange, and consecutive equally spaced quantities. The returned formatter might implementIIncrementalFormatter, in which case its method can be used to reduce redundant information between adjacent quantities.- Specified by:
getFormatterResolvingin classKindOfQuantity<TimestampUnit>
-
getDeltaKind
public KindOfQuantity<LinearUnit> getDeltaKind()
- Specified by:
getDeltaKindin classKindOfQuantity<TimestampUnit>
-
getDefaultUnit
public TimestampUnit getDefaultUnit()
- Specified by:
getDefaultUnitin classKindOfQuantity<TimestampUnit>
-
parsePersisted
public ITypedQuantity<TimestampUnit> parsePersisted(java.lang.String persistedQuantity) throws QuantityConversionException
Description copied from class:KindOfQuantityParse a persisted string. Only guaranteed to be able to parse strings produced byIQuantity.persistableString()for quantities of this kind of quantity. Only use this on persisted strings, never for interactive input.- Specified by:
parsePersistedin interfaceIConstraint<IQuantity>- Specified by:
parsePersistedin classKindOfQuantity<TimestampUnit>- Parameters:
persistedQuantity- persisted string to parse- Returns:
- a valid quantity for this kind of quantity
- Throws:
QuantityConversionException- if parsing failed
-
parseInteractive
public ITypedQuantity<TimestampUnit> parseInteractive(java.lang.String interactiveQuantity) throws QuantityConversionException
Description copied from class:KindOfQuantityParse an interactive string. Only guaranteed to be able to parse strings produced byIQuantity.interactiveFormat()for quantities of this kind of quantity and in the same locale. Only use this for interactive input, never for persisted strings.- Specified by:
parseInteractivein interfaceIConstraint<IQuantity>- Specified by:
parseInteractivein classKindOfQuantity<TimestampUnit>- Parameters:
interactiveQuantity- interactive string to parse- Returns:
- a valid quantity for this kind of quantity
- Throws:
QuantityConversionException- if parsing failed
-
-