Android Calendar to Date Convert getDate(Calendar calendar)

Here you can find the source of getDate(Calendar calendar)

Description

get Date

License

BEER-WARE LICENSE

Declaration

public static HashMap<String, Object> getDate(Calendar calendar) 

Method Source Code

//package com.java2s;
//License from project: BEER-WARE LICENSE 

import java.util.Calendar;
import java.util.HashMap;

public class Main {
    public static final String YEAR = "year";
    public static final String MONTH = "mon";
    public static final String DAY = "day";
    public static final String HOUR = "hour";
    public static final String MIN = "min";

    public static HashMap<String, Object> getDate(Calendar calendar) {
        final HashMap<String, Object> date = new HashMap<String, Object>();
        date.put(YEAR, calendar.get(Calendar.YEAR));
        date.put(MONTH, calendar.get(Calendar.MONTH) + 1);
        date.put(DAY, calendar.get(Calendar.DAY_OF_MONTH));
        date.put(HOUR, calendar.get(Calendar.HOUR_OF_DAY));
        date.put(MIN, calendar.get(Calendar.MINUTE));

        return date;
    }// w w w.  j a  v a 2s. c  om
}

Related

  1. Calendar2Date(Calendar c)
  2. getDate(Context context, Calendar calendar)