Time Type

Time - time type, the format is hh:mm, and it is encapsulated with "" when used

Define Time: Time time = "<hh:mm>"

example:

Time time = "09:30"

Methods of the Time type:

  • Time.now(): Get the hour and minute of the current time

    example:

Time t = Time.now()

  • time.withHour(<Integer hour>): set the hour of the time and return the new time

  Return value type: Time

  example:

time.withHoue(13) //return: 13:30

  • time.withMinute(<Integer day>): set the minute of the time and return the new time

  Return value type: Time

  example:

time.withMinute(50) //return: 9:50

  • time.toTimestamp(): date to timestamp

  Return value type: BigDecimal

  example:

time.toTimestamp() //return: 4260000

  • time.hour: get the hour in the time

    example:

time.hour //return: 9

  • time.minute: Get the minute in the time

    example:

time.minute // return: 30

2024-07-12
0 0