java.time.LocalTime.toString() Method Example



Description

The java.time.LocalTime.toString() method outputs this date as a String, such as 10:15.

Declaration

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

public String toString()

Return Value

a string representation of this date, not null.

Example

The following example shows the usage of java.time.LocalTime.toString() 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.toString());  
   }
}

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

14:39:25.743
Advertisements