Get todays date in format "2015-05-06" - Java java.time

Java examples for java.time:Today

Description

Get todays date in format "2015-05-06"

Demo Code


//package com.java2s;
import java.time.LocalDate;

public class Main {
    /**//w  ww. j a v a 2 s.co  m
     *
     * Get todays date
     * 
     * @return String todays date - format "2015-05-06"
     */
    public static String getTodaysDate() {
        LocalDate today = LocalDate.now();
        return today.toString();
    }
}

Related Tutorials