parse string in format yyyy-MM-dd-H to LocalDateTime - Java java.time

Java examples for java.time:LocalDateTime

Description

parse string in format yyyy-MM-dd-H to LocalDateTime

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 LocalDateTime parse(String date) {
        return LocalDateTime.parse(date, DATE_FORMAT);
    }// w  w w  .  ja v a  2 s .  co m
}

Related Tutorials