Java LocalDateTime Calculate parseStringToLocalDateTimeWithSpecifiedTime(String strDate, String time)

Here you can find the source of parseStringToLocalDateTimeWithSpecifiedTime(String strDate, String time)

Description

Parses a String into a LocalDateTime with a specified time

License

Open Source License

Exception

Parameter Description
ParseException an exception

Declaration

public static LocalDateTime parseStringToLocalDateTimeWithSpecifiedTime(String strDate, String time)
        throws DateTimeParseException 

Method Source Code

//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);
    }
}

Related

  1. isWithin(LocalDateTime start, LocalDateTime end)
  2. last(LocalDateTime from, int dayOfWeek)
  3. localDateTime2LocalDate(LocalDateTime localDateTime)
  4. ms2LocalDateTime(final long ms)
  5. oldDateToISO8601LocalDateTime(Date nextColumnDate)
  6. parseTimeStamp(LocalDateTime actualDate, LocalDateTime checkedDate, boolean isDateFrom)
  7. printDateTime(LocalDateTime dateTime)
  8. relativeDateTime(final LocalDateTime contextDate, final String str, final boolean add)
  9. safeCreateFromValue(LocalDateTime datetime, int year, int month, int day, int hour, int minute, int second)