Package java.time

Examples of java.time.Instant


        System.out.println(month);          // DECEMBER

        long minuteOfDay = sylvester.getLong(ChronoField.MINUTE_OF_DAY);
        System.out.println(minuteOfDay);    // 1439

        Instant instant = sylvester
                .atZone(ZoneId.systemDefault())
                .toInstant();

        Date legacyDate = Date.from(instant);
        System.out.println(legacyDate);     // Wed Dec 31 23:59:59 CET 2014
View Full Code Here


  @Test
  public void testClockFixed() throws Exception {
    // A clock which always returns a fixed date/time - in this case 'now', in UTC
    Clock clock = Clock.fixed(Instant.now(), ZoneId.of("UTC"));

    Instant instant1 = clock.instant();
    Thread.sleep(1);
    Instant instant2 = clock.instant();

    assertThat(instant2, is(instant1));
  }
View Full Code Here

        }
       
       
       
//        long then = System.currentTimeMillis();
        Instant then = Instant.now();
       
        System.out.println("Starting worker threads..");
        Thread[] workers = new Thread[CORES];
        for (int i = 0; i < CORES; ++i) {
            Runnable job = jobs[i];
            workers[i] = new Thread(job);
            workers[i].start();
        }
        System.out.println("All threads has been started..");
       
        for (Thread worker : workers) {
            // Let administrator thread wait for all workers..
            worker.join();
        }
       
//        long now = System.currentTimeMillis();
        Instant now = Instant.now();
       
        printFirstMiddleLast(integers);
        System.out.println("Job took (ms): " + Duration.between(then, now));
    }
View Full Code Here

        /*
         * We need to convert to legacy Date using instant until JAX-RS can
         * handle Java 8 types...
         */
        LocalDate ldBirth = LocalDate.parse(isoDateOfBirth, DateTimeFormatter.ISO_LOCAL_DATE);
        Instant iBirth = ldBirth.atStartOfDay(ZoneId.systemDefault()).toInstant();

        Random r = new Random(123);

        EmployeeEntity newEmployee = new EmployeeEntity(r.nextLong(), name, Date.from(iBirth));

View Full Code Here

    @GET
    @Path("data-types")
    public String echoDataTypes(@QueryParam("string") final String string,
            @QueryParam("int") final int integer, @QueryParam("big-decimal") final BigDecimal bigDecimal,
            @QueryParam("boolean") final boolean bool, @QueryParam("date") final String date) {
        Instant instant = Instant.parse(date);
        return "String: " + string + ", Int: " + integer + ", Big decimal: " + bigDecimal
                + ", Boolean: " + bool + ", Date: " + instant.toString();
    }
View Full Code Here

            // Now we can display the wallet seed as appropriate.
            passwordButton.setText("Remove password");
        }

        // Set the date picker to show the birthday of this wallet.
        Instant creationTime = Instant.ofEpochSecond(seed.getCreationTimeSeconds());
        LocalDate origDate = creationTime.atZone(ZoneId.systemDefault()).toLocalDate();
        datePicker.setValue(origDate);

        // Set the mnemonic seed words.
        final List<String> mnemonicCode = seed.getMnemonicCode();
        checkNotNull(mnemonicCode);    // Already checked for encryption.
View Full Code Here

TOP

Related Classes of java.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.