Example usage for java.time LocalTime atDate

List of usage examples for java.time LocalTime atDate

Introduction

In this page you can find the example usage for java.time LocalTime atDate.

Prototype

public LocalDateTime atDate(LocalDate date) 

Source Link

Document

Combines this time with a date to create a LocalDateTime .

Usage

From source file:Main.java

public static void main(String[] args) {
    LocalTime l = LocalTime.now();
    LocalDateTime t = l.atDate(LocalDate.now());
    System.out.println(t);/*w  ww . j  a v  a2s .c  om*/
}

From source file:Main.java

public static Date toDate(LocalTime localTime) {
    Instant instant = localTime.atDate(LocalDate.now()).atZone(ZoneId.systemDefault()).toInstant();
    return toDate(instant);
}

From source file:com.hengyi.japp.tools.DateTimeUtil.java

public static Date toDate(LocalTime localTime) {
    return localTime == null ? null : toDate(localTime.atDate(LocalDate.of(1977, Month.JANUARY, 1)));
}

From source file:com.hengyi.japp.tools.DateTimeUtil.java

public static Date toDate(LocalDate localDate, LocalTime localTime) {
    return (localDate == null || localTime == null) ? null : toDate(localTime.atDate(localDate));
}

From source file:org.darkware.wpman.util.TimeWindow.java

/**
 * Calculates the next time when a given hour and minute occur, based from the given start time.
 *
 * @param after The time to start searching from.
 * @param hour The hour to search for./*  ww  w .j  ava 2 s. com*/
 * @param minute The minute to search for.
 * @return A {@code DateTime} corresponding to the hour and minute declared which is explicitly after
 * the start time.
 */
public static LocalDateTime nextTime(final LocalDateTime after, final int hour, final int minute) {
    LocalTime time = LocalTime.of(hour, minute);
    LocalDate afterDate = after.toLocalDate();
    if (!time.isAfter(after.toLocalTime()))
        afterDate = afterDate.plus(1, ChronoUnit.DAYS);
    return time.atDate(afterDate);
}