Close

Java Date Time - LocalDateTime.withMinute() Examples

Java Date Time Java Java API 


Class:

java.time.LocalDateTime

java.lang.Objectjava.lang.Objectjava.time.LocalDateTimejava.time.LocalDateTimejava.time.temporal.TemporalTemporaljava.time.temporal.TemporalAdjusterTemporalAdjusterjava.time.chrono.ChronoLocalDateTimeChronoLocalDateTimejava.io.SerializableSerializableLogicBig

Method:

public LocalDateTime withMinute(int minute)

Returns a copy of this LocalDateTime with the minute-of-hour field replaced with the specified minute value. This method will throw exception for an invalid value of minute e.g. 61.



Examples


package com.logicbig.example.localdatetime;

import java.time.LocalDateTime;

public class WithMinuteExample {

public static void main (String... args) {
LocalDateTime d = LocalDateTime.of(2000, 1, 2,
10, 20, 22);
LocalDateTime d2 = d.withMinute(30);
System.out.println(d2);
}
}

Output

2000-01-02T10:30:22




See Also