java.time.LocalTime.toSecondOfDay() Method Example



Description

The java.time.LocalTime.toSecondOfDay() method extracts the time as seconds of day, from 0 to 24 * 60 * 60 - 1.

Declaration

Following is the declaration for java.time.LocalTime.toSecondOfDay() method.

public int toSecondOfDay()

Return Value

the second-of-day equivalent to this time.

Example

The following example shows the usage of java.time.LocalTime.toSecondOfDay() method.

package com.tutorialspoint;

import java.time.LocalTime;

public class LocalTimeDemo {
   public static void main(String[] args) {
 
      LocalTime time = LocalTime.now();
      System.out.println(time.toSecondOfDay());  
   }
}

Let us compile and run the above program, this will produce the following result −

52728
Advertisements