format LocalDateTime as yyyy-MM-dd-H - Java java.time

Java examples for java.time:LocalDateTime

Description

format LocalDateTime as yyyy-MM-dd-H

Demo Code


//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
}

Related Tutorials