Java SQL Date From toDate(Calendar cal)

Here you can find the source of toDate(Calendar cal)

Description

toDate (cal): convert Calendar to Date

License

Open Source License

Parameter

Parameter Description
cal Calendar

Return

Date

Declaration

public static Date toDate(Calendar cal) 

Method Source Code


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

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

public class Main {
    /**//from ww w .jav a  2s.  c  o  m
     * <code>toDate (date): </code> convert SQL Date to Date
     * @param date   SQL Date
     * @return Date
     */
    public static Date toDate(java.sql.Date date) {
        if (date == null)
            return null;
        Date javaDate = new Date(date.getTime());
        return javaDate;
    }

    /**
     * <code>toDate (cal):</code> convert Calendar to Date
     * @param cal   Calendar
     * @return Date
     */
    public static Date toDate(Calendar cal) {
        if (cal == null)
            return null;
        return cal.getTime();
    }

    /**
     * <code>getTime (timezone):</code> get the time now
     * @param zone   time zone
     * @return Calendar instance
     */
    public static Calendar getTime(TimeZone zone) {
        return Calendar.getInstance(zone);
    }
}

Related

  1. getDateTime()
  2. getDateTime()
  3. getDateTime()
  4. getDateTime(final int year, final int month, final int day, final int hour, final int minute, final int second)
  5. getDateTime(Object value)
  6. toDate(int value)
  7. toDate(java.sql.Date sqlDate)
  8. toDate(java.util.Date date)
  9. toDate(Object date)