Java Day getDaysMonthYear(Date date)

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

Description

get Days Month Year

License

Apache License

Declaration

public static Hashtable<String, Object> getDaysMonthYear(Date date) 

Method Source Code

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

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Hashtable;

public class Main {
    public static Hashtable<String, Object> getDaysMonthYear(Date date) {
        Hashtable<String, Object> _value = new Hashtable<String, Object>();

        Calendar _calendar = Calendar.getInstance();

        _calendar.setTime(date);/* ww  w.j  a  v a  2s. co m*/

        int _days = _calendar.getActualMaximum(Calendar.DAY_OF_MONTH);

        String _month = getMonth(date);

        String _year = getYear(date);

        _value.put("days", _days);

        _value.put("month", _month);

        _value.put("year", _year);

        return _value;
    }

    public static String getMonth(Date date) {
        SimpleDateFormat _sdf = new SimpleDateFormat("MM");

        String _value = _sdf.format(date);

        return _value;
    }

    public static String getYear(Date date) {
        SimpleDateFormat _sdf = new SimpleDateFormat("yyyy");

        String _value = _sdf.format(date);

        return _value;
    }
}

Related

  1. getDaysByYearMonth(String ym)
  2. getDaysForDate(String date)
  3. getDaysforYear()
  4. getDaysFrom2Dates(Calendar calendar1, Calendar calendar2)
  5. getDaysLater(int day)
  6. getDaysOfDates(Date first, Date second)
  7. getdaysslice(String startdate, String enddate)
  8. getDayStr(int i, String formatStr)
  9. getDayStringOfDate(Date date)