Java LocalDate Create getCurrentLocalDate()

Here you can find the source of getCurrentLocalDate()

Description

get the current date and time in LocalDate format

License

Open Source License

Return

current LocalDate

Declaration

public static LocalDate getCurrentLocalDate() 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.text.DateFormat;

import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.time.format.FormatStyle;

import java.util.Calendar;

import java.util.Locale;

public class Main {
    private static final DateFormat dateFormat = new SimpleDateFormat("dd.MM.yyyy");
    private static final DateTimeFormatter germanFormatter = DateTimeFormatter.ofLocalizedDate(FormatStyle.MEDIUM)
            .withLocale(Locale.GERMAN);

    /**//  w w  w .j a v a  2 s.  com
     * get the current date and time in LocalDate format
     * 
     * @return current LocalDate
     */
    public static LocalDate getCurrentLocalDate() {
        Calendar currentDateTime = Calendar.getInstance();
        LocalDate currentDate = LocalDate.parse(dateFormat.format(currentDateTime.getTime()).toString(),
                germanFormatter);
        return currentDate;
    }
}

Related

  1. getCurrentLocalDate()
  2. getCurrentLocalDate()
  3. getLocalDate(int year, int atDay)
  4. getLocalDate(java.util.Date date)
  5. getLocalDate(long timeInMillis)
  6. toLocalDate(Calendar calendar)