Java LocalDate to toDBString(LocalDate date)

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

Description

to DB String

License

Open Source License

Declaration

public static String toDBString(LocalDate date) 

Method Source Code

//package com.java2s;
/* //from w  ww.ja va  2  s. com
 * 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.text.DateFormat;

import java.text.SimpleDateFormat;

import java.time.LocalDate;
import java.time.LocalDateTime;

public class Main {
    public static String toDBString(LocalDate date) {
        DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        return format.format(date);
    }

    public static String toDBString(LocalDateTime date) {
        DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        return format.format(date);
    }
}

Related

  1. from(LocalDate localDate, LocalTime localTime, ZoneOffset zoneOffset)
  2. fromLocalDate(LocalDate date)
  3. fromLocalDate(LocalDate date, TimeZone timeZone)
  4. toBadDate(LocalDate localDate, ZoneId timezone)
  5. toCalendar(LocalDate localDate)