Here you can find the source of parseStringToLocalDateTimeWithSpecifiedTime(String strDate, String time)
Parameter | Description |
---|---|
ParseException | an exception |
public static LocalDateTime parseStringToLocalDateTimeWithSpecifiedTime(String strDate, String time) throws DateTimeParseException
//package com.java2s; //License from project: Open Source License import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.time.format.DateTimeParseException; public class Main { public static final DateTimeFormatter localDateTimeFormatter = DateTimeFormatter.ofPattern("d MMM yyyy HH:mm"); /**//from w ww . j a v a2 s. co m * Parses a String into a LocalDateTime with a specified time * @throws ParseException */ public static LocalDateTime parseStringToLocalDateTimeWithSpecifiedTime(String strDate, String time) throws DateTimeParseException { return parseStringToLocalDateTime(strDate + " " + time); } /** * Parses a String into a LocalDateTime * @throws ParseException */ public static LocalDateTime parseStringToLocalDateTime(String strDate) throws DateTimeParseException { return LocalDateTime.parse(strDate, localDateTimeFormatter); } }