java.lang.Object
java.lang.Record
appointmentplanner.api.LocalDay
- Record Components:
zone
- the time zone for this daydate
- the date of this day
Utility class to do zoned time conversion.
- Author:
- Pieter van den Hombergh
p.vandenhombergh@fontys.nl
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionat
(int hm, int m) Get the instant at the given hours and minutes.date()
Returns the value of thedate
record component.dateOfInstant
(Instant instant) Get the LocalDate of an instant according to this timezone.final boolean
Indicates whether some other object is "equal to" this one.final int
hashCode()
Returns a hash code value for this object.static LocalDay
now()
Return the LocalDay for the default time zone at the current date.ofLocalTime
(LocalTime localTime) Get the time as instant.plusDays
(int days) Add x numbers of days to this LocalDay.timeOfInstant
(Instant instant) Get the LocalTime of an instant according to this day.final String
toString()
Returns a string representation of this record class.zone()
Returns the value of thezone
record component.
-
Constructor Details
-
LocalDay
Default constructor. Make sure zone and date are not null.- Parameters:
zone
- the zoneIddate
- the date
-
LocalDay
public LocalDay()Create a LocalDay based on the system default timezone and the current date.
-
-
Method Details
-
ofLocalTime
Get the time as instant.- Parameters:
localTime
- the local time- Returns:
- the time as an instant at this date and timezone
-
timeOfInstant
Get the LocalTime of an instant according to this day.- Parameters:
instant
- to convert to LocalTime- Returns:
- the LocalTime of the given instant
-
dateOfInstant
Get the LocalDate of an instant according to this timezone.- Parameters:
instant
- to convert to LocalDate- Returns:
- the LocalDate of the given instant
-
plusDays
Add x numbers of days to this LocalDay.- Parameters:
days
- to add- Returns:
- the new LocalDay shifted forward or backward in time.
-
at
Get the instant at the given hours and minutes.- Parameters:
hm
- the hoursm
- the minutes- Returns:
- Instant at the given ours and minutes
-
now
Return the LocalDay for the default time zone at the current date.- Returns:
- the day
-
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. -
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. -
equals
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 withObjects::equals(Object,Object)
. -
zone
Returns the value of thezone
record component.- Returns:
- the value of the
zone
record component
-
date
Returns the value of thedate
record component.- Returns:
- the value of the
date
record component
-