Java LocalDateTime Calculate setTime(LocalDateTime source, String time)

Here you can find the source of setTime(LocalDateTime source, String time)

Description

set Time

License

Open Source License

Declaration

public static LocalDateTime setTime(LocalDateTime source, String time) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.time.LocalDateTime;
import java.time.LocalTime;

import java.time.format.DateTimeFormatter;

public class Main {
    private static DateTimeFormatter timeFormatter = DateTimeFormatter.ofPattern("HH:mm");

    public static LocalDateTime setTime(LocalDateTime source, String time) {
        LocalTime tmp = LocalTime.parse(time, timeFormatter);
        return source.withHour(tmp.getHour()) //
                .withMinute(tmp.getMinute());
    }/*from   ww w .ja  v a  2  s .com*/
}

Related

  1. parseTimeStamp(LocalDateTime actualDate, LocalDateTime checkedDate, boolean isDateFrom)
  2. printDateTime(LocalDateTime dateTime)
  3. relativeDateTime(final LocalDateTime contextDate, final String str, final boolean add)
  4. safeCreateFromValue(LocalDateTime datetime, int year, int month, int day, int hour, int minute, int second)
  5. secondsBetween(LocalDateTime date1, LocalDateTime date2)
  6. shiftDateTime(String timex, LocalDateTime reference, boolean future)
  7. shouldSend(Optional emailSentOpt, int timeToWait)
  8. sleepUntil(LocalDateTime next)
  9. toCalendar(final LocalDateTime localDateTime)