Java Code Examples for java.time.chrono.Chronology#from()

The following examples show how to use java.time.chrono.Chronology#from() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DateTimeFormatterBuilder.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@Override
long getValue(DateTimePrintContext context, long value) {
    long absValue = Math.abs(value);
    int baseValue = this.baseValue;
    if (baseDate != null) {
        Chronology chrono = Chronology.from(context.getTemporal());
        baseValue = chrono.date(baseDate).get(field);
    }
    if (value >= baseValue && value < baseValue + EXCEED_POINTS[minWidth]) {
        // Use the reduced value if it fits in minWidth
        return absValue % EXCEED_POINTS[minWidth];
    }
    // Otherwise truncate to fit in maxWidth
    return absValue % EXCEED_POINTS[maxWidth];
}
 
Example 2
Source File: DateTimeFormatterBuilder.java    From desugar_jdk_libs with GNU General Public License v2.0 5 votes vote down vote up
@Override
long getValue(DateTimePrintContext context, long value) {
    long absValue = Math.abs(value);
    int baseValue = this.baseValue;
    if (baseDate != null) {
        Chronology chrono = Chronology.from(context.getTemporal());
        baseValue = chrono.date(baseDate).get(field);
    }
    if (value >= baseValue && value < baseValue + EXCEED_POINTS[minWidth]) {
        // Use the reduced value if it fits in minWidth
        return absValue % EXCEED_POINTS[minWidth];
    }
    // Otherwise truncate to fit in maxWidth
    return absValue % EXCEED_POINTS[maxWidth];
}
 
Example 3
Source File: JulianFields.java    From desugar_jdk_libs with GNU General Public License v2.0 5 votes vote down vote up
@Override
public ChronoLocalDate resolve(
        Map<TemporalField, Long> fieldValues, TemporalAccessor partialTemporal, ResolverStyle resolverStyle) {
    long value = fieldValues.remove(this);
    Chronology chrono = Chronology.from(partialTemporal);
    if (resolverStyle == ResolverStyle.LENIENT) {
        return chrono.dateEpochDay(Math8.subtractExact(value, offset));
    }
    range().checkValidValue(value, this);
    return chrono.dateEpochDay(value - offset);
}
 
Example 4
Source File: JulianFields.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@Override
public ChronoLocalDate resolve(
        Map<TemporalField, Long> fieldValues, TemporalAccessor partialTemporal, ResolverStyle resolverStyle) {
    long value = fieldValues.remove(this);
    Chronology chrono = Chronology.from(partialTemporal);
    if (resolverStyle == ResolverStyle.LENIENT) {
        return chrono.dateEpochDay(Math.subtractExact(value, offset));
    }
    range().checkValidValue(value, this);
    return chrono.dateEpochDay(value - offset);
}
 
Example 5
Source File: JulianFields.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
@Override
public ChronoLocalDate resolve(
        Map<TemporalField, Long> fieldValues, TemporalAccessor partialTemporal, ResolverStyle resolverStyle) {
    long value = fieldValues.remove(this);
    Chronology chrono = Chronology.from(partialTemporal);
    if (resolverStyle == ResolverStyle.LENIENT) {
        return chrono.dateEpochDay(Math.subtractExact(value, offset));
    }
    range().checkValidValue(value, this);
    return chrono.dateEpochDay(value - offset);
}
 
Example 6
Source File: JulianFields.java    From j2objc with Apache License 2.0 5 votes vote down vote up
@Override
public ChronoLocalDate resolve(
        Map<TemporalField, Long> fieldValues, TemporalAccessor partialTemporal, ResolverStyle resolverStyle) {
    long value = fieldValues.remove(this);
    Chronology chrono = Chronology.from(partialTemporal);
    if (resolverStyle == ResolverStyle.LENIENT) {
        return chrono.dateEpochDay(Math.subtractExact(value, offset));
    }
    range().checkValidValue(value, this);
    return chrono.dateEpochDay(value - offset);
}
 
Example 7
Source File: DateTimeFormatterBuilder.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@Override
long getValue(DateTimePrintContext context, long value) {
    long absValue = Math.abs(value);
    int baseValue = this.baseValue;
    if (baseDate != null) {
        Chronology chrono = Chronology.from(context.getTemporal());
        baseValue = chrono.date(baseDate).get(field);
    }
    if (value >= baseValue && value < baseValue + EXCEED_POINTS[minWidth]) {
        // Use the reduced value if it fits in minWidth
        return absValue % EXCEED_POINTS[minWidth];
    }
    // Otherwise truncate to fit in maxWidth
    return absValue % EXCEED_POINTS[maxWidth];
}
 
Example 8
Source File: JulianFields.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public ChronoLocalDate resolve(
        Map<TemporalField, Long> fieldValues, TemporalAccessor partialTemporal, ResolverStyle resolverStyle) {
    long value = fieldValues.remove(this);
    Chronology chrono = Chronology.from(partialTemporal);
    if (resolverStyle == ResolverStyle.LENIENT) {
        return chrono.dateEpochDay(Math.subtractExact(value, offset));
    }
    range().checkValidValue(value, this);
    return chrono.dateEpochDay(value - offset);
}
 
Example 9
Source File: JulianFields.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
public ChronoLocalDate resolve(
        Map<TemporalField, Long> fieldValues, TemporalAccessor partialTemporal, ResolverStyle resolverStyle) {
    long value = fieldValues.remove(this);
    Chronology chrono = Chronology.from(partialTemporal);
    if (resolverStyle == ResolverStyle.LENIENT) {
        return chrono.dateEpochDay(Math.subtractExact(value, offset));
    }
    range().checkValidValue(value, this);
    return chrono.dateEpochDay(value - offset);
}
 
Example 10
Source File: DateTimeFormatterBuilder.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
long getValue(DateTimePrintContext context, long value) {
    long absValue = Math.abs(value);
    int baseValue = this.baseValue;
    if (baseDate != null) {
        Chronology chrono = Chronology.from(context.getTemporal());
        baseValue = chrono.date(baseDate).get(field);
    }
    if (value >= baseValue && value < baseValue + EXCEED_POINTS[minWidth]) {
        // Use the reduced value if it fits in minWidth
        return absValue % EXCEED_POINTS[minWidth];
    }
    // Otherwise truncate to fit in maxWidth
    return absValue % EXCEED_POINTS[maxWidth];
}
 
Example 11
Source File: DateTimeFormatterBuilder.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
long getValue(DateTimePrintContext context, long value) {
    long absValue = Math.abs(value);
    int baseValue = this.baseValue;
    if (baseDate != null) {
        Chronology chrono = Chronology.from(context.getTemporal());
        baseValue = chrono.date(baseDate).get(field);
    }
    if (value >= baseValue && value < baseValue + EXCEED_POINTS[minWidth]) {
        // Use the reduced value if it fits in minWidth
        return absValue % EXCEED_POINTS[minWidth];
    }
    // Otherwise truncate to fit in maxWidth
    return absValue % EXCEED_POINTS[maxWidth];
}
 
Example 12
Source File: JulianFields.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
public ChronoLocalDate resolve(
        Map<TemporalField, Long> fieldValues, TemporalAccessor partialTemporal, ResolverStyle resolverStyle) {
    long value = fieldValues.remove(this);
    Chronology chrono = Chronology.from(partialTemporal);
    if (resolverStyle == ResolverStyle.LENIENT) {
        return chrono.dateEpochDay(Math.subtractExact(value, offset));
    }
    range().checkValidValue(value, this);
    return chrono.dateEpochDay(value - offset);
}
 
Example 13
Source File: DateTimeFormatterBuilder.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
@Override
long getValue(DateTimePrintContext context, long value) {
    long absValue = Math.abs(value);
    int baseValue = this.baseValue;
    if (baseDate != null) {
        Chronology chrono = Chronology.from(context.getTemporal());
        baseValue = chrono.date(baseDate).get(field);
    }
    if (value >= baseValue && value < baseValue + EXCEED_POINTS[minWidth]) {
        // Use the reduced value if it fits in minWidth
        return absValue % EXCEED_POINTS[minWidth];
    }
    // Otherwise truncate to fit in maxWidth
    return absValue % EXCEED_POINTS[maxWidth];
}
 
Example 14
Source File: TCKIsoChronology.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions=NullPointerException.class)
public void factory_from_TemporalAccessor_null() {
    Chronology.from(null);
}
 
Example 15
Source File: TCKIsoChronology.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions=NullPointerException.class)
public void factory_from_TemporalAccessor_null() {
    Chronology.from(null);
}
 
Example 16
Source File: TCKIsoChronology.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions=NullPointerException.class)
public void factory_from_TemporalAccessor_null() {
    Chronology.from(null);
}
 
Example 17
Source File: DateTimeFormatterBuilder.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public boolean format(DateTimePrintContext context, StringBuilder buf) {
    Chronology chrono = Chronology.from(context.getTemporal());
    return formatter(context.getLocale(), chrono).toPrinterParser(false).format(context, buf);
}
 
Example 18
Source File: DateTimeFormatterBuilder.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
@Override
public boolean format(DateTimePrintContext context, StringBuilder buf) {
    Chronology chrono = Chronology.from(context.getTemporal());
    return formatter(context.getLocale(), chrono).toPrinterParser(false).format(context, buf);
}
 
Example 19
Source File: TCKIsoChronology.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions=NullPointerException.class)
public void factory_from_TemporalAccessor_null() {
    Chronology.from(null);
}
 
Example 20
Source File: DateTimeFormatterBuilder.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
@Override
public boolean format(DateTimePrintContext context, StringBuilder buf) {
    Chronology chrono = Chronology.from(context.getTemporal());
    return formatter(context.getLocale(), chrono).toPrinterParser(false).format(context, buf);
}