LocalTime withSecond(int second) example

Description

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

Syntax

withSecond has the following syntax.


public LocalTime withSecond(int second)

Example

The following example shows how to use withSecond.


import java.time.LocalTime;
/*w  w w  .  jav a  2s .c om*/
public class Main {
  public static void main(String[] args) {
    LocalTime l = LocalTime.now();
    LocalTime s = l.withSecond(1234);
    System.out.println(s);
  }
}




















Home »
  Java Date Time »
    java.time Reference »




Clock
DayOfWeek
Duration
Instant
LocalDate
LocalDateTime
LocalTime
Month
MonthDay
OffsetDateTime
OffsetTime
Period
Year
YearMonth
ZonedDateTime
ZoneId
ZoneOffset