Java Code Examples for java.time.Instant#MIN

The following examples show how to use java.time.Instant#MIN . 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: TCKInstant.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
@DataProvider(name="adjustInto")
Object[][] data_adjustInto() {
    return new Object[][]{
            {Instant.ofEpochSecond(10, 200), Instant.ofEpochSecond(20), Instant.ofEpochSecond(10, 200), null},
            {Instant.ofEpochSecond(10, -200), Instant.now(), Instant.ofEpochSecond(10, -200), null},
            {Instant.ofEpochSecond(-10), Instant.EPOCH, Instant.ofEpochSecond(-10), null},
            {Instant.ofEpochSecond(10), Instant.MIN, Instant.ofEpochSecond(10), null},
            {Instant.ofEpochSecond(10), Instant.MAX, Instant.ofEpochSecond(10), null},

            {Instant.ofEpochSecond(10, 200), LocalDateTime.of(1970, 1, 1, 0, 0, 20).toInstant(ZoneOffset.UTC), Instant.ofEpochSecond(10, 200), null},
            {Instant.ofEpochSecond(10, 200), OffsetDateTime.of(1970, 1, 1, 0, 0, 20, 10, ZoneOffset.UTC), OffsetDateTime.of(1970, 1, 1, 0, 0, 10, 200, ZoneOffset.UTC), null},
            {Instant.ofEpochSecond(10, 200), OffsetDateTime.of(1970, 1, 1, 0, 0, 20, 10, OFFSET_PTWO), OffsetDateTime.of(1970, 1, 1, 2, 0, 10, 200, OFFSET_PTWO), null},
            {Instant.ofEpochSecond(10, 200), ZonedDateTime.of(1970, 1, 1, 0, 0, 20, 10, ZONE_PARIS), ZonedDateTime.of(1970, 1, 1, 1, 0, 10, 200, ZONE_PARIS), null},

            {Instant.ofEpochSecond(10, 200), LocalDateTime.of(1970, 1, 1, 0, 0, 20), null, DateTimeException.class},
            {Instant.ofEpochSecond(10, 200), null, null, NullPointerException.class},

    };
}
 
Example 2
Source File: TCKInstant.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
@DataProvider(name="with")
Object[][] data_with() {
    return new Object[][]{
            {Instant.ofEpochSecond(10, 200), Instant.ofEpochSecond(20), Instant.ofEpochSecond(20), null},
            {Instant.ofEpochSecond(10), Instant.ofEpochSecond(20, -100), Instant.ofEpochSecond(20, -100), null},
            {Instant.ofEpochSecond(-10), Instant.EPOCH, Instant.ofEpochSecond(0), null},
            {Instant.ofEpochSecond(10), Instant.MIN, Instant.MIN, null},
            {Instant.ofEpochSecond(10), Instant.MAX, Instant.MAX, null},

            {Instant.ofEpochSecond(10, 200), LocalDateTime.of(1970, 1, 1, 0, 0, 20).toInstant(ZoneOffset.UTC), Instant.ofEpochSecond(20), null},

            {Instant.ofEpochSecond(10, 200), LocalDateTime.of(1970, 1, 1, 0, 0, 20), null, DateTimeException.class},
            {Instant.ofEpochSecond(10, 200), null, null, NullPointerException.class},

    };
}
 
Example 3
Source File: TCKInstant.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
@DataProvider(name="with")
Object[][] data_with() {
    return new Object[][]{
            {Instant.ofEpochSecond(10, 200), Instant.ofEpochSecond(20), Instant.ofEpochSecond(20), null},
            {Instant.ofEpochSecond(10), Instant.ofEpochSecond(20, -100), Instant.ofEpochSecond(20, -100), null},
            {Instant.ofEpochSecond(-10), Instant.EPOCH, Instant.ofEpochSecond(0), null},
            {Instant.ofEpochSecond(10), Instant.MIN, Instant.MIN, null},
            {Instant.ofEpochSecond(10), Instant.MAX, Instant.MAX, null},

            {Instant.ofEpochSecond(10, 200), LocalDateTime.of(1970, 1, 1, 0, 0, 20).toInstant(ZoneOffset.UTC), Instant.ofEpochSecond(20), null},

            {Instant.ofEpochSecond(10, 200), LocalDateTime.of(1970, 1, 1, 0, 0, 20), null, DateTimeException.class},
            {Instant.ofEpochSecond(10, 200), null, null, NullPointerException.class},

    };
}
 
Example 4
Source File: TCKInstant.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@DataProvider(name="adjustInto")
Object[][] data_adjustInto() {
    return new Object[][]{
            {Instant.ofEpochSecond(10, 200), Instant.ofEpochSecond(20), Instant.ofEpochSecond(10, 200), null},
            {Instant.ofEpochSecond(10, -200), Instant.now(), Instant.ofEpochSecond(10, -200), null},
            {Instant.ofEpochSecond(-10), Instant.EPOCH, Instant.ofEpochSecond(-10), null},
            {Instant.ofEpochSecond(10), Instant.MIN, Instant.ofEpochSecond(10), null},
            {Instant.ofEpochSecond(10), Instant.MAX, Instant.ofEpochSecond(10), null},

            {Instant.ofEpochSecond(10, 200), LocalDateTime.of(1970, 1, 1, 0, 0, 20).toInstant(ZoneOffset.UTC), Instant.ofEpochSecond(10, 200), null},
            {Instant.ofEpochSecond(10, 200), OffsetDateTime.of(1970, 1, 1, 0, 0, 20, 10, ZoneOffset.UTC), OffsetDateTime.of(1970, 1, 1, 0, 0, 10, 200, ZoneOffset.UTC), null},
            {Instant.ofEpochSecond(10, 200), OffsetDateTime.of(1970, 1, 1, 0, 0, 20, 10, OFFSET_PTWO), OffsetDateTime.of(1970, 1, 1, 2, 0, 10, 200, OFFSET_PTWO), null},
            {Instant.ofEpochSecond(10, 200), ZonedDateTime.of(1970, 1, 1, 0, 0, 20, 10, ZONE_PARIS), ZonedDateTime.of(1970, 1, 1, 1, 0, 10, 200, ZONE_PARIS), null},

            {Instant.ofEpochSecond(10, 200), LocalDateTime.of(1970, 1, 1, 0, 0, 20), null, DateTimeException.class},
            {Instant.ofEpochSecond(10, 200), null, null, NullPointerException.class},

    };
}
 
Example 5
Source File: TCKInstant.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
@DataProvider(name="adjustInto")
Object[][] data_adjustInto() {
    return new Object[][]{
            {Instant.ofEpochSecond(10, 200), Instant.ofEpochSecond(20), Instant.ofEpochSecond(10, 200), null},
            {Instant.ofEpochSecond(10, -200), Instant.now(), Instant.ofEpochSecond(10, -200), null},
            {Instant.ofEpochSecond(-10), Instant.EPOCH, Instant.ofEpochSecond(-10), null},
            {Instant.ofEpochSecond(10), Instant.MIN, Instant.ofEpochSecond(10), null},
            {Instant.ofEpochSecond(10), Instant.MAX, Instant.ofEpochSecond(10), null},

            {Instant.ofEpochSecond(10, 200), LocalDateTime.of(1970, 1, 1, 0, 0, 20).toInstant(ZoneOffset.UTC), Instant.ofEpochSecond(10, 200), null},
            {Instant.ofEpochSecond(10, 200), OffsetDateTime.of(1970, 1, 1, 0, 0, 20, 10, ZoneOffset.UTC), OffsetDateTime.of(1970, 1, 1, 0, 0, 10, 200, ZoneOffset.UTC), null},
            {Instant.ofEpochSecond(10, 200), OffsetDateTime.of(1970, 1, 1, 0, 0, 20, 10, OFFSET_PTWO), OffsetDateTime.of(1970, 1, 1, 2, 0, 10, 200, OFFSET_PTWO), null},
            {Instant.ofEpochSecond(10, 200), ZonedDateTime.of(1970, 1, 1, 0, 0, 20, 10, ZONE_PARIS), ZonedDateTime.of(1970, 1, 1, 1, 0, 10, 200, ZONE_PARIS), null},

            {Instant.ofEpochSecond(10, 200), LocalDateTime.of(1970, 1, 1, 0, 0, 20), null, DateTimeException.class},
            {Instant.ofEpochSecond(10, 200), null, null, NullPointerException.class},

    };
}
 
Example 6
Source File: DictCore.java    From PolyGlot with MIT License 6 votes vote down vote up
/**
 * Used for test loading reversion XMLs. Cannot successfully load actual revision into functioning DictCore
 * @param reversion 
 * @return
 */
public String testLoadReversion(byte[] reversion) {
    String errorLog;
    
    try {
        CustHandler handler = IOHandler.getHandlerFromByteArray(reversion, this);
        IOHandler.parseHandlerByteArray(reversion, handler);

        errorLog = handler.getErrorLog();
        // errorLog += handler.getWarningLog(); // warnings may be disregarded here
    } catch (IOException | ParserConfigurationException | SAXException e) {
        IOHandler.writeErrorLog(e);
        errorLog = e.getLocalizedMessage();
    }
    
    // if no save time present, simply timestamp for current time (only relevant for first time revision log added)
    if (lastSaveTime == Instant.MIN) {
        lastSaveTime = Instant.now();
    }
    
    return errorLog;
}
 
Example 7
Source File: TCKInstant.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
@DataProvider(name="with")
Object[][] data_with() {
    return new Object[][]{
            {Instant.ofEpochSecond(10, 200), Instant.ofEpochSecond(20), Instant.ofEpochSecond(20), null},
            {Instant.ofEpochSecond(10), Instant.ofEpochSecond(20, -100), Instant.ofEpochSecond(20, -100), null},
            {Instant.ofEpochSecond(-10), Instant.EPOCH, Instant.ofEpochSecond(0), null},
            {Instant.ofEpochSecond(10), Instant.MIN, Instant.MIN, null},
            {Instant.ofEpochSecond(10), Instant.MAX, Instant.MAX, null},

            {Instant.ofEpochSecond(10, 200), LocalDateTime.of(1970, 1, 1, 0, 0, 20).toInstant(ZoneOffset.UTC), Instant.ofEpochSecond(20), null},

            {Instant.ofEpochSecond(10, 200), LocalDateTime.of(1970, 1, 1, 0, 0, 20), null, DateTimeException.class},
            {Instant.ofEpochSecond(10, 200), null, null, NullPointerException.class},

    };
}
 
Example 8
Source File: InstantSerializerTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
protected Instant[] getTestData() {
	final Random rnd = new Random(874597969123412341L);

	return new Instant[] {
		Instant.EPOCH, Instant.MIN, Instant.MAX,
		Instant.ofEpochSecond(rndSeconds(rnd),	rndNanos(rnd)),
		Instant.ofEpochSecond(1534135584,949495),
		Instant.ofEpochSecond(56090783)
	};
}
 
Example 9
Source File: InstantSerializerTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
protected Instant[] getTestData() {
	final Random rnd = new Random(874597969123412341L);

	return new Instant[] {
		Instant.EPOCH, Instant.MIN, Instant.MAX,
		Instant.ofEpochSecond(rndSeconds(rnd),	rndNanos(rnd)),
		Instant.ofEpochSecond(1534135584,949495),
		Instant.ofEpochSecond(56090783)
	};
}
 
Example 10
Source File: Criteria.java    From cognition with Apache License 2.0 5 votes vote down vote up
public Criteria() {
  this.accumuloTable = "";

  this.dateStart = Instant.MIN;
  this.dateEnd = Instant.MAX;

  //note: enum map does not serialize with kryo for spark so use HashMap
  this.stringMatches = new HashMap<>();
  this.keywords = new HashSet<>();

}
 
Example 11
Source File: InstantSerializerTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Override
protected Instant[] getTestData() {
	final Random rnd = new Random(874597969123412341L);

	return new Instant[] {
		Instant.EPOCH, Instant.MIN, Instant.MAX,
		Instant.ofEpochSecond(rndSeconds(rnd),	rndNanos(rnd)),
		Instant.ofEpochSecond(1534135584,949495),
		Instant.ofEpochSecond(56090783)
	};
}
 
Example 12
Source File: TCKInstant.java    From j2objc with Apache License 2.0 4 votes vote down vote up
@Override
protected List<TemporalAccessor> samples() {
    TemporalAccessor[] array = {TEST_12345_123456789, Instant.MIN, Instant.MAX, Instant.EPOCH};
    return Arrays.asList(array);
}
 
Example 13
Source File: FileTime.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Converts this {@code FileTime} object to an {@code Instant}.
 *
 * <p> The conversion creates an {@code Instant} that represents the
 * same point on the time-line as this {@code FileTime}.
 *
 * <p> {@code FileTime} can store points on the time-line further in the
 * future and further in the past than {@code Instant}. Conversion
 * from such further time points saturates to {@link Instant#MIN} if
 * earlier than {@code Instant.MIN} or {@link Instant#MAX} if later
 * than {@code Instant.MAX}.
 *
 * @return  an instant representing the same point on the time-line as
 *          this {@code FileTime} object
 * @since 1.8
 */
public Instant toInstant() {
    if (instant == null) {
        long secs = 0L;
        int nanos = 0;
        switch (unit) {
            case DAYS:
                secs = scale(value, SECONDS_PER_DAY,
                             Long.MAX_VALUE/SECONDS_PER_DAY);
                break;
            case HOURS:
                secs = scale(value, SECONDS_PER_HOUR,
                             Long.MAX_VALUE/SECONDS_PER_HOUR);
                break;
            case MINUTES:
                secs = scale(value, SECONDS_PER_MINUTE,
                             Long.MAX_VALUE/SECONDS_PER_MINUTE);
                break;
            case SECONDS:
                secs = value;
                break;
            case MILLISECONDS:
                secs = Math.floorDiv(value, MILLIS_PER_SECOND);
                nanos = (int)Math.floorMod(value, MILLIS_PER_SECOND)
                        * NANOS_PER_MILLI;
                break;
            case MICROSECONDS:
                secs = Math.floorDiv(value, MICROS_PER_SECOND);
                nanos = (int)Math.floorMod(value, MICROS_PER_SECOND)
                        * NANOS_PER_MICRO;
                break;
            case NANOSECONDS:
                secs = Math.floorDiv(value, NANOS_PER_SECOND);
                nanos = (int)Math.floorMod(value, NANOS_PER_SECOND);
                break;
            default : throw new AssertionError("Unit not handled");
        }
        if (secs <= MIN_SECOND)
            instant = Instant.MIN;
        else if (secs >= MAX_SECOND)
            instant = Instant.MAX;
        else
            instant = Instant.ofEpochSecond(secs, nanos);
    }
    return instant;
}
 
Example 14
Source File: TCKInstant.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected List<TemporalAccessor> samples() {
    TemporalAccessor[] array = {TEST_12345_123456789, Instant.MIN, Instant.MAX, Instant.EPOCH};
    return Arrays.asList(array);
}
 
Example 15
Source File: FileTime.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Converts this {@code FileTime} object to an {@code Instant}.
 *
 * <p> The conversion creates an {@code Instant} that represents the
 * same point on the time-line as this {@code FileTime}.
 *
 * <p> {@code FileTime} can store points on the time-line further in the
 * future and further in the past than {@code Instant}. Conversion
 * from such further time points saturates to {@link Instant#MIN} if
 * earlier than {@code Instant.MIN} or {@link Instant#MAX} if later
 * than {@code Instant.MAX}.
 *
 * @return  an instant representing the same point on the time-line as
 *          this {@code FileTime} object
 * @since 1.8
 */
public Instant toInstant() {
    if (instant == null) {
        long secs = 0L;
        int nanos = 0;
        switch (unit) {
            case DAYS:
                secs = scale(value, SECONDS_PER_DAY,
                             Long.MAX_VALUE/SECONDS_PER_DAY);
                break;
            case HOURS:
                secs = scale(value, SECONDS_PER_HOUR,
                             Long.MAX_VALUE/SECONDS_PER_HOUR);
                break;
            case MINUTES:
                secs = scale(value, SECONDS_PER_MINUTE,
                             Long.MAX_VALUE/SECONDS_PER_MINUTE);
                break;
            case SECONDS:
                secs = value;
                break;
            case MILLISECONDS:
                secs = Math.floorDiv(value, MILLIS_PER_SECOND);
                nanos = (int)Math.floorMod(value, MILLIS_PER_SECOND)
                        * NANOS_PER_MILLI;
                break;
            case MICROSECONDS:
                secs = Math.floorDiv(value, MICROS_PER_SECOND);
                nanos = (int)Math.floorMod(value, MICROS_PER_SECOND)
                        * NANOS_PER_MICRO;
                break;
            case NANOSECONDS:
                secs = Math.floorDiv(value, NANOS_PER_SECOND);
                nanos = (int)Math.floorMod(value, NANOS_PER_SECOND);
                break;
            default : throw new AssertionError("Unit not handled");
        }
        if (secs <= MIN_SECOND)
            instant = Instant.MIN;
        else if (secs >= MAX_SECOND)
            instant = Instant.MAX;
        else
            instant = Instant.ofEpochSecond(secs, nanos);
    }
    return instant;
}
 
Example 16
Source File: BuilderEntityState.java    From attic-polygene-java with Apache License 2.0 4 votes vote down vote up
@Override
public Instant lastModified()
{
    return Instant.MIN;
}
 
Example 17
Source File: NodeAdminStateUpdater.java    From vespa with Apache License 2.0 4 votes vote down vote up
private T invalidateAndGet() {
    refreshAt = Instant.MIN;
    return get();
}
 
Example 18
Source File: FileTime.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Converts this {@code FileTime} object to an {@code Instant}.
 *
 * <p> The conversion creates an {@code Instant} that represents the
 * same point on the time-line as this {@code FileTime}.
 *
 * <p> {@code FileTime} can store points on the time-line further in the
 * future and further in the past than {@code Instant}. Conversion
 * from such further time points saturates to {@link Instant#MIN} if
 * earlier than {@code Instant.MIN} or {@link Instant#MAX} if later
 * than {@code Instant.MAX}.
 *
 * @return  an instant representing the same point on the time-line as
 *          this {@code FileTime} object
 * @since 1.8
 */
public Instant toInstant() {
    if (instant == null) {
        long secs = 0L;
        int nanos = 0;
        switch (unit) {
            case DAYS:
                secs = scale(value, SECONDS_PER_DAY,
                             Long.MAX_VALUE/SECONDS_PER_DAY);
                break;
            case HOURS:
                secs = scale(value, SECONDS_PER_HOUR,
                             Long.MAX_VALUE/SECONDS_PER_HOUR);
                break;
            case MINUTES:
                secs = scale(value, SECONDS_PER_MINUTE,
                             Long.MAX_VALUE/SECONDS_PER_MINUTE);
                break;
            case SECONDS:
                secs = value;
                break;
            case MILLISECONDS:
                secs = Math.floorDiv(value, MILLIS_PER_SECOND);
                nanos = (int)Math.floorMod(value, MILLIS_PER_SECOND)
                        * NANOS_PER_MILLI;
                break;
            case MICROSECONDS:
                secs = Math.floorDiv(value, MICROS_PER_SECOND);
                nanos = (int)Math.floorMod(value, MICROS_PER_SECOND)
                        * NANOS_PER_MICRO;
                break;
            case NANOSECONDS:
                secs = Math.floorDiv(value, NANOS_PER_SECOND);
                nanos = (int)Math.floorMod(value, NANOS_PER_SECOND);
                break;
            default : throw new AssertionError("Unit not handled");
        }
        if (secs <= MIN_SECOND)
            instant = Instant.MIN;
        else if (secs >= MAX_SECOND)
            instant = Instant.MAX;
        else
            instant = Instant.ofEpochSecond(secs, nanos);
    }
    return instant;
}
 
Example 19
Source File: TCKInstant.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected List<TemporalAccessor> samples() {
    TemporalAccessor[] array = {TEST_12345_123456789, Instant.MIN, Instant.MAX, Instant.EPOCH};
    return Arrays.asList(array);
}
 
Example 20
Source File: ModelState.java    From anomaly-detection with Apache License 2.0 3 votes vote down vote up
/**
 * Constructor.
 *
 * @param model ML model
 * @param modelId Id of model partition
 * @param detectorId Id of detector this model partition is used for
 * @param modelType type of model
 * @param lastUsedTime time when the ML model was used last time
 */
public ModelState(T model, String modelId, String detectorId, String modelType, Instant lastUsedTime) {
    this.model = model;
    this.modelId = modelId;
    this.detectorId = detectorId;
    this.modelType = modelType;
    this.lastUsedTime = lastUsedTime;
    this.lastCheckpointTime = Instant.MIN;
}