Example usage for java.time Instant MAX

List of usage examples for java.time Instant MAX

Introduction

In this page you can find the example usage for java.time Instant MAX.

Prototype

Instant MAX

To view the source code for java.time Instant MAX.

Click Source Link

Document

The maximum supported Instant , '1000000000-12-31T23:59:59.999999999Z'.

Usage

From source file:Main.java

public static void main(String[] args) {
    Instant instant = Instant.MAX;
    System.out.println(instant.getEpochSecond());

}

From source file:com.qwazr.externalizor.SimpleTime.java

public SimpleTime() {

    calNullValue = null;/*from  w ww  .  j  a  v a  2  s  .  c om*/
    calValue = Calendar.getInstance();
    calValue.setTimeInMillis(RandomUtils.nextLong());
    calArray = new Calendar[] { calNullValue, calValue };
    calList = new ArrayList(Arrays.asList(calValue, calNullValue));

    dateNullValue = null;
    dateValue = new Date(RandomUtils.nextLong());
    dateArray = new Date[] { dateNullValue, dateValue };
    dateList = new ArrayList(Arrays.asList(dateValue, dateNullValue));

    durationNullValue = null;
    durationValue = Duration.ofSeconds(RandomUtils.nextLong());
    durationArray = new Duration[] { durationNullValue, durationValue };
    durationList = new ArrayList(Arrays.asList(durationValue, durationNullValue));

    instantNullValue = null;
    instantValue = Instant.ofEpochSecond(RandomUtils.nextLong(0, Instant.MAX.getEpochSecond()));
    instantArray = new Instant[] { instantNullValue, instantValue };
    instantList = new ArrayList(Arrays.asList(instantValue, instantNullValue));

    localTimeNullValue = null;
    localTimeValue = LocalTime.of(RandomUtils.nextInt(0, 24), RandomUtils.nextInt(0, 60),
            RandomUtils.nextInt(0, 60));
    localTimeArray = new LocalTime[] { localTimeNullValue, localTimeValue };
    localTimeList = new ArrayList(Arrays.asList(localTimeValue, localTimeNullValue));

    localDateNullValue = null;
    localDateValue = LocalDate.of(RandomUtils.nextInt(2000, 3000), RandomUtils.nextInt(1, 13),
            RandomUtils.nextInt(1, 29));
    localDateArray = new LocalDate[] { localDateNullValue, localDateValue };
    localDateList = new ArrayList(Arrays.asList(localDateValue, localDateNullValue));

    localDateTimeNullValue = null;
    localDateTimeValue = LocalDateTime.of(
            LocalDate.of(RandomUtils.nextInt(2000, 3000), RandomUtils.nextInt(1, 13),
                    RandomUtils.nextInt(1, 29)),
            LocalTime.of(RandomUtils.nextInt(0, 24), RandomUtils.nextInt(0, 60), RandomUtils.nextInt(0, 60)));
    localDateTimeArray = new LocalDateTime[] { localDateTimeNullValue, localDateTimeValue };
    localDateTimeList = new ArrayList(Arrays.asList(localDateTimeValue, localDateTimeNullValue));

    monthDayNullValue = null;
    monthDayValue = MonthDay.of(RandomUtils.nextInt(1, 13), RandomUtils.nextInt(1, 29));
    monthDayArray = new MonthDay[] { monthDayNullValue, monthDayValue };
    monthDayList = new ArrayList(Arrays.asList(monthDayValue, monthDayNullValue));

    periodNullValue = null;
    periodValue = Period.of(RandomUtils.nextInt(0, Year.MAX_VALUE), RandomUtils.nextInt(1, 13),
            RandomUtils.nextInt(1, 29));
    periodArray = new Period[] { periodNullValue, periodValue };
    periodList = new ArrayList(Arrays.asList(periodValue, periodNullValue));

    yearNullValue = null;
    yearValue = Year.of(RandomUtils.nextInt(0, Year.MAX_VALUE));
    yearArray = new Year[] { yearNullValue, yearValue };
    yearList = new ArrayList(Arrays.asList(yearValue, yearNullValue));

}

From source file:com.github.aptd.simulation.elements.graph.network.local.CPlatform.java

@Override
protected Instant determinenextstatechange() {
    // a platform has no processes going on
    return Instant.MAX;
}

From source file:com.github.aptd.simulation.elements.passenger.CPassengerSource.java

protected synchronized Instant determinenextstatechange() {
    if (m_passengersgenerated >= m_passengers)
        return Instant.MAX;
    return Instant.ofEpochMilli(m_startmillis + (long) Math.ceil(
            m_distribution.inverseCumulativeProbability(1.0 * (m_passengersgenerated + 1) / m_passengers)));
}

From source file:com.github.aptd.simulation.elements.train.CDoor.java

@Override
protected Instant determinenextstatechange() {
    switch (m_state) {
    case CLOSED_LOCKED:
    case CLOSED_RELEASED:
    case OPEN_BUSY:
    case OPEN_BUSY_SHALL_CLOSE:
    case OPEN_CLOSEABLE:
        return Instant.MAX;
    case OPENING:
    case OPENING_SHALL_CLOSE:
        return m_lastcontinuousupdate.plus(Math.round((m_width - m_openwidth) / m_openingspeed),
                ChronoUnit.SECONDS);
    case OPEN_FREE:
    case OPEN_FREE_SHALL_CLOSE:
        return m_lastcontinuousupdate.plus(Math.round(m_minfreetimetoclose - m_freetime), ChronoUnit.SECONDS);
    case CLOSING:
    case CLOSING_LOCKED:
        return m_lastcontinuousupdate.plus(Math.round(m_openwidth / m_closingspeed), ChronoUnit.SECONDS);
    default:/*from   w w  w  .  j a va2s.  c  o m*/
        return Instant.MAX;
    }
}

From source file:com.github.aptd.simulation.elements.train.CTrain.java

@Override
protected final synchronized Instant determinenextstatechange() {
    switch (m_state) {
    case DRIVING:
        return m_lastcontinuousupdate.plus(
                Math.round((m_timetable.get(m_ttindex).m_tracklength - m_positionontrack) / DRIVING_SPEED),
                ChronoUnit.SECONDS);
    case WAITING_TO_DRIVE:
        return m_doorsnotclosedlocked.isEmpty() ? m_laststatechange : Instant.MAX;
    case ARRIVED:
        if (m_ttindex + 1 >= m_timetable.size())
            return Instant.MAX;
        return Collections.max(Arrays.asList(m_timetable.get(m_ttindex).m_publisheddeparture,
                m_laststatechange.plus(30, ChronoUnit.SECONDS)));
    default://from ww  w  .  j a  v  a2 s.c om
        return m_laststatechange.plus(30, ChronoUnit.SECONDS);
    }
}

From source file:com.github.aptd.simulation.elements.passenger.CPassenger.java

@Override
protected Instant determinenextstatechange() {
    switch (m_state) {
    case MOVING_THROUGH_STATION:
        return m_lastcontinuousupdate.plus(
                Math.round((m_distancetonextplatform - m_distancewalked) / m_speedatstation),
                ChronoUnit.SECONDS);
    case ENTERING_TRAIN:
        return m_lastcontinuousupdate.plus(Math.round(m_entranceduration - m_dooruse), ChronoUnit.SECONDS);
    case LEAVING_TRAIN:
        return m_lastcontinuousupdate.plus(Math.round(m_exitduration - m_dooruse), ChronoUnit.SECONDS);
    default:/*from   www.ja  va  2 s. com*/
        return Instant.MAX;
    }
}

From source file:org.apache.tinkerpop.gremlin.server.GremlinServerHttpIntegrateTest.java

@Test
public void should200OnPOSTWithGremlinJsonEndcodedBodyForJavaTime() throws Exception {
    // basic test of java.time.* serialization over JSON from the server perspective. more complete tests
    // exist in gremlin-core
    final CloseableHttpClient httpclient = HttpClients.createDefault();
    final HttpPost httppost = new HttpPost(TestClientFactory.createURLString());
    httppost.addHeader("Content-Type", "application/json");
    httppost.setEntity(new StringEntity("{\"gremlin\":\"java.time.Instant.MAX\"}", Consts.UTF_8));

    try (final CloseableHttpResponse response = httpclient.execute(httppost)) {
        assertEquals(200, response.getStatusLine().getStatusCode());
        assertEquals("application/json", response.getEntity().getContentType().getValue());
        final String json = EntityUtils.toString(response.getEntity());
        final JsonNode node = mapper.readTree(json);
        assertEquals(Instant.MAX, Instant.parse(node.get("result").get("data").get(GraphSONTokens.VALUEPROP)
                .get(0).get(GraphSONTokens.VALUEPROP).asText()));
    }//from   w  w  w .  ja  v a 2s  . c  o  m
}