Java SQL Date From toSqlDate(Date date)

Here you can find the source of toSqlDate(Date date)

Description

to Sql Date

License

Open Source License

Declaration

public static java.sql.Date toSqlDate(Date date) 

Method Source Code


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

import java.util.Date;
import java.util.Calendar;

public class Main {
    public static java.sql.Date toSqlDate(Date date) {
        return new java.sql.Date(date.getTime());
    }/*from   w w w .j a v  a 2s  .  c o  m*/

    public static Date getTime(int year, int month, int day, int hour, int minute) {
        return getTime(year, month, day, hour, minute, 0);
    }

    public static Date getTime(int year, int month, int day, int hour, int minute, int second) {
        Calendar cal = Calendar.getInstance();
        cal.set(year, month - 1, day, hour, minute, second);
        cal.set(Calendar.MILLISECOND, 0);

        return cal.getTime();
    }

    public static Date getTime(int hour, int minute) {
        return getTime(hour, minute, 0);
    }

    public static Date getTime(int hour, int minute, int second) {
        Calendar cal = Calendar.getInstance();
        cal.set(Calendar.HOUR_OF_DAY, hour);
        cal.set(Calendar.MINUTE, minute);
        cal.set(Calendar.SECOND, second);
        cal.set(Calendar.MILLISECOND, 0);

        return cal.getTime();
    }
}

Related

  1. toDateMidnight(java.util.Date d)
  2. toDateStr(java.util.Date d)
  3. toSqlDate(Calendar calendar)
  4. toSqlDate(Date date)
  5. toSqlDate(Date date)
  6. toSqlDate(Date dt)
  7. toSqlDate(final Date date)
  8. toSqlDate(final String _text, final String _dateFormat)
  9. toSQLDate(java.util.Date date)