Java Today today()

Here you can find the source of today()

Description

today

License

Apache License

Declaration

public static Date today() 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.util.Date;

public class Main {
    public static Date today() {
        java.util.Calendar now = java.util.Calendar.getInstance();
        //Month in java.util.Calendar is 0-based, so add 1 to simulate .NET:
        return dateForYMDHMS(now.get(java.util.Calendar.YEAR), now.get(java.util.Calendar.MONTH) + 1,
                now.get(java.util.Calendar.DATE), 0, 0, 0);
    }/*from   w  w  w  .ja  va  2s  . c om*/

    public static Date dateForYMDHMS(int year, int month, int day, int hour, int minute, int second) {
        java.util.Calendar cal = java.util.Calendar.getInstance();
        cal.clear();
        //Month in java.util.Calendar is 0-based, so subtract 1:
        cal.set(year, month - 1, day, hour, minute, second);
        return cal.getTime();
    }
}

Related

  1. today()
  2. today()
  3. today()
  4. Today()
  5. today()
  6. today()
  7. today()
  8. today()
  9. today()