Package org.joda.time

Examples of org.joda.time.Instant


    public static GJChronology getInstance(
            DateTimeZone zone,
            long gregorianCutover,
            int minDaysInFirstWeek) {
       
        Instant cutoverInstant;
        if (gregorianCutover == DEFAULT_CUTOVER.getMillis()) {
            cutoverInstant = null;
        } else {
            cutoverInstant = new Instant(gregorianCutover);
        }
        return getInstance(zone, cutoverInstant, minDaysInFirstWeek);
    }
View Full Code Here


    protected void assemble(Fields fields) {
        Object[] params = (Object[])getParam();

        JulianChronology julian = (JulianChronology)params[0];
        GregorianChronology gregorian = (GregorianChronology)params[1];
        Instant cutoverInstant = (Instant)params[2];
        iCutoverMillis = cutoverInstant.getMillis();

        iJulianChronology = julian;
        iGregorianChronology = gregorian;
        iCutoverInstant = cutoverInstant;
View Full Code Here

    validator = new FutureValidatorForReadableInstant();
  }

  @Test
  public void testIsValidForInstant() {
    Instant future = new Instant().plus( 31557600000L );
    Instant past = new Instant().minus( 31557600000L );

    Assert.assertTrue( validator.isValid( null, null ) );
    Assert.assertTrue( validator.isValid( future, null ) );
    Assert.assertFalse( validator.isValid( past, null ) );
  }
View Full Code Here

    validator = new PastValidatorForReadableInstant();
  }

  @Test
  public void testIsValidForInstant() {
    Instant future = new Instant().plus( 31557600000L );
    Instant past = new Instant().minus( 31557600000L );

    Assert.assertTrue( validator.isValid( null, null ) );
    Assert.assertTrue( validator.isValid( past, null ) );
    Assert.assertFalse( validator.isValid( future, null ) );
  }
View Full Code Here

*/
public class SystemClock implements Clock {

  @Override
  public Instant now() {
    return new Instant();
  }
View Full Code Here

    out.println("Control-C to stop");
    out.println("JOB                  HOST                           STATE    THROTTLED?");
    final DateTimeFormatter formatter = DateTimeFormat.forPattern("YYYY-MM-dd HH:mm:ss");
    while (true) {

      final Instant now = new Instant();
      out.printf("-------------------- ------------------------------ -------- "
          + "---------- [%s UTC]%n", now.toString(formatter));
      for (TargetAndClient cc : clients) {
        final Optional<Target> target = cc.getTarget();
        if (clients.size() > 1) {
          final String header;
          if (target.isPresent()) {
View Full Code Here

      FAR_FUTURE_EXPIRING_JOB_ID, FAR_FUTURE_EXPIRING_JOB
  );

  @Test
  public void testExpiredJobReaper() throws Exception {
    when(mockClock.now()).thenReturn(new Instant(CURRENT_TS));
    when(masterModel.getJobs()).thenReturn(JOBS);

    when(masterModel.getJobStatus(any(JobId.class)))
      .then(new Answer<JobStatus>() {
        @Override
View Full Code Here

        .setRestartCount(2)
        .setTimeRangeMillis(1000)
        .build();

    assertFalse(controller.isFlapping());
    when(clock.now()).thenReturn(new Instant(0));

    // get controller into flapping state
    controller.started();
    controller.exited();
    assertFalse(controller.isFlapping());      // not failed enough *yet*

    controller.started();
    controller.exited();
    assertTrue(controller.isFlapping());       // now we failed enough.

    //// See that the state maintains the flapping state.

    controller.started();
    controller.exited();
    assertTrue(controller.isFlapping());
    controller.started();
    controller.exited();
    assertTrue(controller.isFlapping());

    //// Now test that the state will update while the future is running

    controller.started();
    when(clock.now()).thenReturn(new Instant(2000));
    assertFalse(controller.isFlapping());
  }
View Full Code Here

        .setRestartCount(2)
        .setTimeRangeMillis(1000)
        .build();

    assertFalse(controller.isFlapping());
    when(clock.now()).thenReturn(new Instant(0));

    controller.started();
    when(clock.now()).thenReturn(new Instant(1));
    controller.exited(); // 1 second of runtime T=1
    assertFalse(controller.isFlapping());

    controller.started();
    when(clock.now()).thenReturn(new Instant(2));
    controller.exited(); // total of 2ms of runtime T=2
    assertTrue(controller.isFlapping()); // next time job would start would be at t=7 seconds

    controller.started();
    when(clock.now()).thenReturn(new Instant(8));
    controller.exited(); // total of 3ms of runtime T=8 (5 of that is throttle)
    assertTrue(controller.isFlapping()); // next time job would start would be at t=13

    controller.started();
    when(clock.now()).thenReturn(new Instant(1034));
    controller.exited(); // ran 1021ms additionally here, so should disengage flapping T=1034
    assertFalse(controller.isFlapping());
  }
View Full Code Here

            localInstant = iField.set(localInstant, value);
            long result = iZone.convertLocalToUTC(localInstant, false, instant);
            if (get(result) != value) {
                throw new IllegalFieldValueException(iField.getType(), Integer.valueOf(value),
                    "Illegal instant due to time zone offset transition: " +
                    DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ss.SSS").print(new Instant(localInstant)) +
                    " (" + iZone.getID() + ")");
            }
            return result;
        }
View Full Code Here

TOP

Related Classes of org.joda.time.Instant

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.