Java LocalDate Format getLocalDate(String dateStr, String formatStr)

Here you can find the source of getLocalDate(String dateStr, String formatStr)

Description

get Local Date

Declaration

public static LocalDate getLocalDate(String dateStr, String formatStr) 

Method Source Code


//package com.java2s;
import com.google.common.base.Strings;
import java.time.*;

import java.time.format.DateTimeFormatter;
import java.time.temporal.TemporalAccessor;
import java.util.Date;

public class Main {
    public static LocalDate getLocalDate(Date date) {
        return LocalDate.from(date.toInstant());
    }/*  ww w .  ja  v  a 2 s .c o  m*/

    public static LocalDate getLocalDate(String dateStr, String formatStr) {
        if (Strings.isNullOrEmpty(dateStr)) {
            return null;
        }
        final DateTimeFormatter dtf = DateTimeFormatter.ofPattern(formatStr);
        TemporalAccessor temp = dtf.parse(dateStr);
        return LocalDate.from(temp);
    }
}

Related

  1. formatLocalDateJsr310ForJsonPath(LocalDate date)
  2. formatToIsoLocalDate(LocalDate date)
  3. getDateFormatForLocalDate()
  4. getDateStartFormat(LocalDate localDate)
  5. getFormattedDateString(LocalDate date)
  6. isLocalDate(String value, DateTimeFormatter formatter)
  7. parseToLocalDate(String format, String date)