Java LocalDate Format getDateFormatForLocalDate()

Here you can find the source of getDateFormatForLocalDate()

Description

get Date Format For Local Date

License

LGPL

Declaration

public static DateTimeFormatter getDateFormatForLocalDate() 

Method Source Code

//package com.java2s;
/*//  w w  w  .  ja v  a 2 s  .  co  m
 * License GNU LGPL
 * Copyright (C) 2012 Amrullah <amrullah@panemu.com>.
 */

import java.text.DateFormat;

import java.text.SimpleDateFormat;

import java.time.format.DateTimeFormatter;

import java.util.Locale;

public class Main {
    private static Locale loc = new Locale("es", "PY");
    private static DateTimeFormatter dateTimeFormatter;

    public static DateTimeFormatter getDateFormatForLocalDate() {

        if (dateTimeFormatter == null) {
            dateTimeFormatter = DateTimeFormatter
                    .ofPattern(getLocaleDatePattern());
        }
        return dateTimeFormatter;
    }

    private static String getLocaleDatePattern() {
        DateFormat dateFormat = DateFormat.getDateInstance(
                DateFormat.SHORT, loc);
        SimpleDateFormat simpleFormat = (SimpleDateFormat) dateFormat;
        String pattern = simpleFormat.toPattern();
        return pattern;
    }
}

Related

  1. format(final LocalDate source)
  2. formateDate(LocalDate date, String formatStr)
  3. formatLocalDate(LocalDate date)
  4. formatLocalDateJsr310ForJsonPath(LocalDate date)
  5. formatToIsoLocalDate(LocalDate date)
  6. getDateStartFormat(LocalDate localDate)
  7. getFormattedDateString(LocalDate date)
  8. getLocalDate(String dateStr, String formatStr)
  9. isLocalDate(String value, DateTimeFormatter formatter)