Java Year Month getCurrentYearMonthDay()

Here you can find the source of getCurrentYearMonthDay()

Description

get Current Year Month Day

License

Open Source License

Declaration

@SuppressWarnings("deprecation")
    public static final Date getCurrentYearMonthDay() 

Method Source Code

//package com.java2s;

import java.util.*;

public class Main {
    @SuppressWarnings("deprecation")
    public static final Date getCurrentYearMonthDay() {
        Date date = new Date();
        return new Date(date.getYear(), date.getMonth(), date.getDate());
    }//from   www.  ja  v  a 2 s.  c o  m

    public static int getYear(Date date) {
        Calendar cal = Calendar.getInstance();
        cal.setTime(date);
        int year = cal.get(Calendar.YEAR);
        return year;
    }

    public static int getMonth(Date date) {
        Calendar cal = Calendar.getInstance();
        cal.setTime(date);
        int month = cal.get(Calendar.MONTH);
        return (month + 1);
    }
}

Related

  1. Date2Long(int year, int month, int date)
  2. encodeDateTime(int year, int month, int day, int hour, int minutes, int seconds)
  3. getAddedDate(Date date, int addYear, int addMonth, int addDay, int addHour, int addMinute, int addSecond)
  4. getAllDate(String year_month)
  5. getBeginEndDayOfMonth(String yearMonthString)
  6. getCurYearMonth()
  7. getDate(int year, int month, int day)
  8. getDate(int year, int month, int day, int hour, int minute)
  9. getDaysOfMonth(String year, String month)