Java LocalTime plusMinutes() Method
Example
Add 45 minutes to a time:
import java.time.LocalTime;
public class Main {
public static void main(String[] args) {
LocalTime myTime = LocalTime.of(14, 30);
System.out.println(myTime.plusMinutes(45));
}
}
Definition and Usage
The plusMinutes() method returns a new time, a number of minutes after the original time. The hour changes when needed.
The original time is not changed.
Tip: Use the plusHours() method to add hours.
Syntax
public LocalTime plusMinutes(long minutesToAdd)
Parameter Values
| Parameter | Description |
|---|---|
| minutesToAdd | Required. The number of minutes to add. It can be negative. |
Technical Details
| Returns: | A new LocalTime object with the minutes added. |
|---|
Related Pages
❮ Date and Time Methods