Java LocalDateTime Calculate isToday(LocalDateTime dateTime)

Here you can find the source of isToday(LocalDateTime dateTime)

Description

Check if datetime is from today

License

Open Source License

Parameter

Parameter Description
dateTime a datetime

Return

true / false

Declaration

public static boolean isToday(LocalDateTime dateTime) 

Method Source Code


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

import java.time.LocalDate;
import java.time.LocalDateTime;

public class Main {
    /**//from   w  w  w  .j a va 2s.co  m
     * Check if datetime is from today
     *
     * @param dateTime a datetime
     * @return true / false
     */
    public static boolean isToday(LocalDateTime dateTime) {
        LocalDate today = LocalDate.now();
        LocalDate date = dateTime.toLocalDate();
        return date.equals(today);
    }
}

Related

  1. getZonedDateTime(LocalDateTime dateTime, TimeZone timeZone)
  2. isAfter(LocalDateTime endDateTime, LocalDateTime startDateTime)
  3. isAfterNow(LocalDateTime pValidUntil)
  4. isBefore(LocalDateTime dateTime1, LocalDateTime dateTime2)
  5. isOverdue(LocalDateTime dueTime)
  6. isTodayOrYesterday(LocalDateTime date)
  7. isWithin(LocalDateTime start, LocalDateTime end)
  8. last(LocalDateTime from, int dayOfWeek)
  9. localDateTime2LocalDate(LocalDateTime localDateTime)