Record Class LocalDay

java.lang.Object
java.lang.Record
appointmentplanner.api.LocalDay
Record Components:
zone - the time zone for this day
date - the date of this day

public record LocalDay(ZoneId zone, LocalDate date) extends Record
Utility class to do zoned time conversion.
Author:
Pieter van den Hombergh p.vandenhombergh@fontys.nl
  • Constructor Details

    • LocalDay

      public LocalDay(ZoneId zone, LocalDate date)
      Default constructor. Make sure zone and date are not null.
      Parameters:
      zone - the zoneId
      date - the date
    • LocalDay

      public LocalDay()
      Create a LocalDay based on the system default timezone and the current date.
  • Method Details

    • ofLocalTime

      public Instant ofLocalTime(LocalTime localTime)
      Get the time as instant.
      Parameters:
      localTime - the local time
      Returns:
      the time as an instant at this date and timezone
    • timeOfInstant

      public LocalTime timeOfInstant(Instant instant)
      Get the LocalTime of an instant according to this day.
      Parameters:
      instant - to convert to LocalTime
      Returns:
      the LocalTime of the given instant
    • dateOfInstant

      public LocalDate dateOfInstant(Instant instant)
      Get the LocalDate of an instant according to this timezone.
      Parameters:
      instant - to convert to LocalDate
      Returns:
      the LocalDate of the given instant
    • plusDays

      public LocalDay plusDays(int days)
      Add x numbers of days to this LocalDay.
      Parameters:
      days - to add
      Returns:
      the new LocalDay shifted forward or backward in time.
    • at

      public Instant at(int hm, int m)
      Get the instant at the given hours and minutes.
      Parameters:
      hm - the hours
      m - the minutes
      Returns:
      Instant at the given ours and minutes
    • now

      public static LocalDay now()
      Return the LocalDay for the default time zone at the current date.
      Returns:
      the day
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • zone

      public ZoneId zone()
      Returns the value of the zone record component.
      Returns:
      the value of the zone record component
    • date

      public LocalDate date()
      Returns the value of the date record component.
      Returns:
      the value of the date record component