Java Date Time - LocalTime withMinute(int minute) example








LocalTime withMinute(int minute) returns a copy of this LocalTime with the minute-of-hour value altered.

Syntax

withMinute has the following syntax.

public LocalTime withMinute(int minute)

Example

The following example shows how to use withMinute.

import java.time.LocalTime;

public class Main {
  public static void main(String[] args) {
    LocalTime l = LocalTime.now();
    LocalTime s = l.withMinute(34);
    System.out.println(s);
  }
}

The code above generates the following result.