Android Date to String Convert updateDate(DatePicker picker, Date date)

Here you can find the source of updateDate(DatePicker picker, Date date)

Description

Convinient method to update a date in a DatePicker .

Parameter

Parameter Description
picker the date picker
date the date value

Declaration

public static void updateDate(DatePicker picker, Date date) 

Method Source Code

//package com.java2s;

import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import android.widget.DatePicker;

public class Main {
    /**/*from w w w.j  a v a2 s.co m*/
     * Convinient method to update a date in a {@link DatePicker}.
     * @param picker the date picker
     * @param date the date value
     */
    public static void updateDate(DatePicker picker, Date date) {
        if (picker != null && date != null) {
            Calendar c = GregorianCalendar.getInstance();
            c.setTime(date);

            int y = c.get(Calendar.YEAR);
            int m = c.get(Calendar.MONTH);
            int d = c.get(Calendar.DAY_OF_MONTH);

            picker.updateDate(y, m, d);
        }
    }
}

Related

  1. datesToString(final Date start, final int duration)
  2. convertDateToString(Date date)
  3. toSimpleDateFormattedString(Date date)
  4. toStringFromDate(Date date)
  5. toUTCFormattedString(Date date)
  6. date2String(Date date, String s)
  7. date2String(int i, int j, int k)