Java Date Time Java Java API
Class:
java.time.LocalTime
Methods:
public static LocalTime of(int hour,
int minute)
public static LocalTime of(int hour,
int minute,
int second)
public static LocalTime of(int hour,
int minute,
int second,
int nanoOfSecond)
These overloaded static methods return a new instance of LocalTime with the specified hour, minute, second and nano seconds.
If provided values are not valid for the corresponding field, DateTimeException is thrown.
Examples
package com.logicbig.example.localtime;
import java.time.LocalTime;
public class OfExample {
public static void main (String... args) { LocalTime t = LocalTime.of(22, 35); System.out.println(t); }
}
Output22:35
package com.logicbig.example.localtime;
import java.time.LocalTime;
public class OfExample2 {
public static void main (String... args) { LocalTime t = LocalTime.of(22, 35, 40); System.out.println(t); }
}
Output22:35:40
package com.logicbig.example.localtime;
import java.time.LocalTime;
public class OfExample3 {
public static void main (String... args) { LocalTime t = LocalTime.of(22, 35, 40, 500000000); System.out.println(t); } }
Output22:35:40.500
|