get Local Date For String in format dd.MM.yyyy - Java java.time

Java examples for java.time:Format

Description

get Local Date For String in format dd.MM.yyyy

Demo Code

/*//from   w  w w.jav a  2 s  . co m
 * Copyright 2014-2015 Christian Raue
 * MIT License http://opensource.org/licenses/mit-license.php
 */
//package com.java2s;
import java.time.LocalDate;

import java.time.format.DateTimeFormatter;

public class Main {
    private static final String PATTERN_DATE = "dd.MM.yyyy";

    /**
     * @param string Datum-Wert
     * @return {@link LocalDate}-Objekt mit entsprechendem Datum-Wert
     */
    public static LocalDate getLocalDateForString(final String string) {
        return LocalDate.parse(string,
                DateTimeFormatter.ofPattern(PATTERN_DATE));
    }
}

Related Tutorials