Here you can find the source of parseDateTime(String dateTimeStr, String format)
Parameter | Description |
---|---|
dateTimeStr | a parameter |
public static LocalDateTime parseDateTime(String dateTimeStr, String format)
//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 { /**/*from w w w. j a va 2 s . c om*/ * Parse date time based on format (e.g yyyy/MM/dd HH:mm:ss) * * @param dateTimeStr * @return */ public static LocalDateTime parseDateTime(String dateTimeStr, String format) { LocalDateTime date = null; try { DateTimeFormatter formatter = DateTimeFormatter.ofPattern(format); date = LocalDateTime.parse(dateTimeStr, formatter); } catch (DateTimeParseException exc) { System.out.printf("%s is not parsable!%n %s", dateTimeStr, exc); } return date; } }