parse LocalDateTime in format yyyy-MMM-dd kkmm - Java java.time

Java examples for java.time:LocalDateTime

Description

parse LocalDateTime in format yyyy-MMM-dd kkmm

Demo Code


//package com.java2s;
import java.time.LocalDateTime;
import java.time.ZoneId;

import java.time.format.DateTimeFormatter;

public class Main {
    private static final DateTimeFormatter formatter = DateTimeFormatter
            .ofPattern("yyyy-MMM-dd kkmm").withZone(ZoneId.of("Z"));

    public static LocalDateTime parseDateAndTime(String date, String time) {
        StringBuilder combined = new StringBuilder();
        combined.append(date).append(" ").append(time);

        return LocalDateTime.parse(combined.toString(), formatter);
    }/* w ww  .  ja v  a  2  s. c o m*/
}

Related Tutorials