Java examples for java.time:LocalDateTime
format LocalDateTime as yyyy-MM-dd-H
//package com.java2s; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; public class Main { private static final DateTimeFormatter DATE_FORMAT = DateTimeFormatter .ofPattern("yyyy-MM-dd-H"); public static String format(LocalDateTime date) { return DATE_FORMAT.format(date); }//from w w w . j a v a2 s . co m }