Here you can find the source of parseTimeStamp(LocalDateTime actualDate, LocalDateTime checkedDate, boolean isDateFrom)
public static LocalDateTime parseTimeStamp(LocalDateTime actualDate, LocalDateTime checkedDate, boolean isDateFrom)
//package com.java2s; //License from project: Open Source License import java.time.LocalDateTime; public class Main { public static LocalDateTime parseTimeStamp(LocalDateTime actualDate, LocalDateTime checkedDate, boolean isDateFrom) { // Check for date if (checkedDate != null && actualDate != null && checkIfDateExist(checkedDate) && !checkIfDateExist(actualDate)) { if (!isDateFrom) { actualDate = checkedDate.toLocalDate().atTime(actualDate.getHour(), actualDate.getMinute()); }/* ww w.j ava 2 s . c om*/ } // Check for time if (checkedDate != null && actualDate != null && checkIfTimeExist(checkedDate) && !checkIfTimeExist(actualDate)) { actualDate = actualDate.toLocalDate().atTime(checkedDate.getHour(), checkedDate.getMinute()); } if (actualDate != null && !checkIfTimeExist(actualDate)) { if (isDateFrom) { actualDate = floorDate(actualDate); } else { actualDate = ceilDate(actualDate); } } return actualDate; } public static boolean checkIfDateExist(LocalDateTime date) { LocalDateTime currentDate = LocalDateTime.now(); return currentDate.getDayOfYear() != date.getDayOfYear() || currentDate.getMonth() != date.getMonth() || currentDate.getYear() != date.getYear(); } public static boolean checkIfTimeExist(LocalDateTime date) { LocalDateTime currentTime = LocalDateTime.now(); return currentTime.getHour() != date.getHour() || currentTime.getMinute() != date.getMinute(); } /** * @@author A0139812A * Performs a "floor" operation on a LocalDateTime, and returns a new LocalDateTime * with time set to 00:00. * * @param dateTime LocalDateTime for operation to be performed on. * @return "Floored" LocalDateTime. */ public static LocalDateTime floorDate(LocalDateTime dateTime) { if (dateTime == null) { return null; } return dateTime.toLocalDate().atTime(0, 0); } /** * Performs a "ceiling" operation on a LocalDateTime, and returns a new LocalDateTime * with time set to 23:59. * * @param dateTime LocalDateTime for operation to be performed on. * @return "Ceiled" LocalDateTime. */ public static LocalDateTime ceilDate(LocalDateTime dateTime) { if (dateTime == null) { return null; } return dateTime.toLocalDate().atTime(23, 59); } }