Java LocalDate to String localDateToString(LocalDate date)

Here you can find the source of localDateToString(LocalDate date)

Description

localDateToString, This returns the supplied date in the ISO-8601 format (uuuu-MM-dd).

License

Open Source License

Declaration

static public String localDateToString(LocalDate date) 

Method Source Code


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

import java.time.*;

public class Main {
    /**//  ww  w.  ja  v  a 2 s  .  c  o  m
     * localDateToString, This returns the supplied date in the ISO-8601 format (uuuu-MM-dd). For
     * any CE years that are between 0 and 9999 inclusive, the output will have a fixed length of 10
     * characters. Years before or after that range will output longer strings. If the date is null,
     * this will return an empty string ("").
     */
    static public String localDateToString(LocalDate date) {
        return localDateToString(date, "");
    }

    /**
     * localDateToString, This returns the supplied date in the ISO-8601 format (uuuu-MM-dd). For
     * any CE years that are between 0 and 9999 inclusive, the output will have a fixed length of 10
     * characters. Years before or after that range will output longer strings. If the date is null,
     * this will return the value of emptyDateString.
     */
    static public String localDateToString(LocalDate date, String emptyDateString) {
        return (date == null) ? emptyDateString : date.toString();
    }
}

Related

  1. dateToFullString(LocalDate date)
  2. dateToString(LocalDate date)
  3. localDate2Str(LocalDate localDate)
  4. toDateString(LocalDate date, String pattern)
  5. toString(LocalDate d)
  6. toString(LocalDate date)