Java SQL Date today()

Here you can find the source of today()

Description

today

License

Open Source License

Declaration

public static java.sql.Date today() 

Method Source Code

//package com.java2s;
// The MIT License (MIT)

import java.util.Calendar;

import java.util.GregorianCalendar;

public class Main {
    public static java.sql.Date today() {
        return new java.sql.Date(todayCalendar().getTimeInMillis());
    }/*w  w  w  . ja va  2  s  .c o  m*/

    public static Calendar todayCalendar() {
        Calendar cal = new GregorianCalendar();
        clearTime(cal);
        return cal;
    }

    public static java.util.Date clearTime(java.util.Date d) {
        Calendar cal = new GregorianCalendar();
        cal.setTime(d);

        clearTime(cal);
        return cal.getTime();
    }

    public static void clearTime(Calendar cal) {
        cal.set(Calendar.HOUR_OF_DAY, 0);
        cal.set(Calendar.MINUTE, 0);
        cal.set(Calendar.SECOND, 0);
        cal.set(Calendar.MILLISECOND, 0);
    }
}

Related

  1. nowPlus(int parts, int value)
  2. parseStringValue(Class returnType, String value)
  3. serialize(Instant sourceValue)
  4. stringToMillis(String str)
  5. toAge(String birthDay)
  6. today()
  7. today()
  8. todaySQL()