Here you can find the source of formatDateAndTime(String dateAndTime)
Parameter | Description |
---|---|
dateAndTime | The String that should be formatted and parsed to a LocalDateTime object. |
public static LocalDateTime formatDateAndTime(String dateAndTime)
//package com.java2s; //License from project: LGPL import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; public class Main { /**//from ww w .ja va 2s . c om * Parses a String to a LocalDateTime object like for example to '2015-12-15 12:30'; * * @param dateAndTime * The String that should be formatted and parsed to a LocalDateTime object. * @return The formatted LocalDateTime Object of the passed String. */ public static LocalDateTime formatDateAndTime(String dateAndTime) { DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"); LocalDateTime formatedDate = LocalDateTime.parse(dateAndTime, formatter); return formatedDate; } }