Java LocalDate to String toString(LocalDate date)

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

Description

to String

License

Open Source License

Declaration

public static String toString(LocalDate date) 

Method Source Code


//package com.java2s;
/* /*w  w w.ja  v  a2s  . c o m*/
 * Copyright (C) 2017 GetMangos
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */

import java.sql.Timestamp;
import java.text.DateFormat;

import java.text.SimpleDateFormat;

import java.time.LocalDate;

import java.util.Date;
import java.util.Locale;

public class Main {
    public static String toString(Timestamp timestamp) {
        DateFormat format = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss", Locale.getDefault());
        return format.format(new Date(timestamp.getTime()));
    }

    public static String toString(LocalDate date) {
        DateFormat format = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss", Locale.getDefault());
        return format.format(date);
    }

    public static String toString(Date date) {
        DateFormat format = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss", Locale.getDefault());
        return format.format(date);
    }
}

Related

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