Java examples for java.time:LocalDateTime
get Time String from LocalDateTime
//package com.java2s; import java.time.DateTimeException; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; public class Main { private static final DateTimeFormatter TIME_FORMATTER = DateTimeFormatter .ofPattern("HH:mm"); public static String getTime(LocalDateTime inputDateTime) { try {/*from w w w . j a va 2 s . c o m*/ return inputDateTime.toLocalTime().format(TIME_FORMATTER); } catch (DateTimeException e) { return null; } } }