List of usage examples for java.time Duration ofHours
public static Duration ofHours(long hours)
From source file:Main.java
public static void main(String[] args) { Duration duration = Duration.ofHours(10); System.out.println(duration); }
From source file:Main.java
public static void main(String[] args) { long twoHoursInSeconds = Duration.ofHours(2).getSeconds(); System.out.println(twoHoursInSeconds); }
From source file:Main.java
public static void main(String[] args) { LocalTime l = LocalTime.now(); LocalTime s = l.plus(Duration.ofHours(1)); System.out.println(s);/*from w w w.ja v a 2 s. c o m*/ }
From source file:Main.java
public static void main(String[] args) { Clock clock = Clock.systemUTC(); Duration duration = Duration.ofHours(3); Clock newClock = Clock.offset(clock, duration); System.out.println(newClock.instant()); }
From source file:Main.java
public static void main(String[] args) { Clock clock = Clock.tickMinutes(ZoneId.systemDefault()); Duration duration = Duration.ofHours(3); Clock newClock = Clock.tick(clock, duration); System.out.println(newClock.instant()); }
From source file:Main.java
public static void main(String[] args) { Duration duration = Duration.ofDays(33); //seconds or nanos Duration duration1 = Duration.ofHours(33); //seconds or nanos Duration duration2 = Duration.ofMillis(33); //seconds or nanos Duration duration3 = Duration.ofMinutes(33); //seconds or nanos Duration duration4 = Duration.ofNanos(33); //seconds or nanos Duration duration5 = Duration.ofSeconds(33); //seconds or nanos Duration duration6 = Duration.between(LocalDate.of(2012, 11, 11), LocalDate.of(2013, 1, 1)); System.out.println(duration6.getSeconds()); System.out.println(duration.getNano()); System.out.println(duration.getSeconds()); }
From source file:Main.java
public static void main(String[] args) { Clock utcClock = Clock.systemUTC(); Clock defaultClock = Clock.systemDefaultZone(); Clock offsetClock = Clock.offset(Clock.systemUTC(), Duration.ofHours(-5)); ZoneId denverTimeZone = ZoneId.of("America/Denver"); ZoneId newYorkTimeZone = ZoneId.of("America/New_York"); ZoneId chicagoTimeZone = ZoneId.of("America/Chicago"); ZoneId losAngelesTimeZone = ZoneId.of("America/Los_Angeles"); Instant instant = Instant.now(defaultClock); Instant instant2 = Instant.now(utcClock); Instant instant3 = Instant.now(offsetClock); System.out.println(instant);// www. j a v a 2 s . c om System.out.println(instant2); System.out.println(instant3.plus(Duration.ofSeconds(90))); System.out.println(instant3.atZone(newYorkTimeZone)); System.out.println(instant3.atZone(chicagoTimeZone)); System.out.println(instant3.atZone(denverTimeZone)); System.out.println(instant3.atZone(losAngelesTimeZone)); }
From source file:Main.java
public static void main(String[] args) { ZonedDateTime _130AMChicagoTime = ZonedDateTime.of(2014, 3, 9, 1, 30, 0, 0, ZoneId.of("America/Chicago")); System.out.println(_130AMChicagoTime.plusHours(3)); System.out.println(_130AMChicagoTime.plus(Duration.ofHours(3))); System.out.println(_130AMChicagoTime.plus(Duration.ofDays(2))); System.out.println(_130AMChicagoTime.plus(Period.ofDays(2))); }
From source file:io.cfp.auth.service.CookieService.java
public Cookie getTokenCookie(String tokenValue) { Cookie tokenCookie = new Cookie("token", tokenValue); tokenCookie.setPath("/"); tokenCookie.setHttpOnly(true); // secure Token to be invisible from // javascript in the browser tokenCookie.setDomain(cookieDomain); tokenCookie.setMaxAge((int) Duration.ofHours(TokenService.TOKEN_EXPIRATION).getSeconds()); return tokenCookie; }
From source file:ch.thp.proto.spring.time.stamp.dataloader.TimesheetLoader.java
@Transactional @Override// w w w.j a v a2 s. c om public void load() { Set<TimesheetEntry> entriesForNed = new HashSet<>(); entriesForNed.add(new TimesheetEntry(UUID.randomUUID().toString(), LocalDate.now().minusDays(1), Duration.ofHours(4), "read something about genealogy. made a comment about the strange color of geoffreys baratheons hair.")); entriesForNed.add(new TimesheetEntry(UUID.randomUUID().toString(), LocalDate.now().minusDays(1), Duration.ofHours(2), "inspected the wall. still white")); entriesForNed.add(new TimesheetEntry(UUID.randomUUID().toString(), LocalDate.now().minusDays(1), Duration.ofHours(2), "lost my head about something")); Timesheet sheetNed = new Timesheet(new TimesheetId(), USER_ID_NED, 24d, 0.8d, LocalDate.now().minusDays(1), entriesForNed); Set<TimesheetEntry> entriesForHeisenberg = new HashSet<>(); entriesForHeisenberg.add(new TimesheetEntry(UUID.randomUUID().toString(), LocalDate.now().minusDays(1), Duration.ofHours(8), "still cooking, what are you expecting?")); entriesForHeisenberg.add(new TimesheetEntry(UUID.randomUUID().toString(), LocalDate.now().minusDays(2), Duration.ofHours(8), "still cooking")); entriesForHeisenberg.add(new TimesheetEntry(UUID.randomUUID().toString(), LocalDate.now().minusDays(3), Duration.ofHours(8), "cooking")); Timesheet sheetHeisenberg = new Timesheet(new TimesheetId(), USER_ID_HEISENBERG, 100, 1.0d, LocalDate.now().minusDays(3), entriesForHeisenberg); Set<TimesheetEntry> entriesForDon = new HashSet<>(); entriesForDon.add(new TimesheetEntry(UUID.randomUUID().toString(), LocalDate.now().minusDays(1), Duration.ofHours(8), "made a witty comment about the usefullness of my minions")); entriesForDon.add(new TimesheetEntry(UUID.randomUUID().toString(), LocalDate.now().minusDays(2), Duration.ofHours(4), "fighting with betty")); entriesForDon.add(new TimesheetEntry(UUID.randomUUID().toString(), LocalDate.now().minusDays(2), Duration.ofHours(10), "made overtime. a lot")); Timesheet sheetDon = new Timesheet(new TimesheetId(), USER_ID_DON, 100, 1.0d, LocalDate.now().minusDays(2), entriesForDon); em.persist(sheetNed); em.persist(sheetHeisenberg); em.persist(sheetDon); }