Java SQL Date Month toDate(int year, int month, int day)

Here you can find the source of toDate(int year, int month, int day)

Description

to Date

License

Open Source License

Declaration

public static Date toDate(int year, int month, int day) 

Method Source Code


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

import java.sql.Date;

public class Main {
    public static Date toDate(int year, int month, int day) {
        String s = year + "-" + two(month + "") + "-" + two(day + "");
        Date d = Date.valueOf(s);
        return d;
    }//  ww w . j av a 2  s .co  m

    public static String two(String msg) {
        return msg.trim().length() < 2 ? "0" + msg : msg.trim();
    }
}

Related

  1. getNextMonthFirstDate(java.sql.Date date)
  2. getNextMonthStartDate(Date date)
  3. getSqlDate(final int iDay, final int iMonth, final int iYear)
  4. getSqlDate(int year, int month, int day)
  5. newDate(Integer year, Integer month, Integer day)
  6. toSqlDate(int year, int month, int day)