Android Calendar Format getSelectedDate(Calendar calendar, String pattern)

Here you can find the source of getSelectedDate(Calendar calendar, String pattern)

Description

get Selected Date

Declaration

public static String getSelectedDate(Calendar calendar, String pattern) 

Method Source Code

//package com.java2s;
import android.text.TextUtils;

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

public class Main {
    public static final String NORMAL_PATTERN = "yyyy-MM-dd HH:mm:ss";

    public static String getSelectedDate(Calendar calendar, String pattern) {

        if (TextUtils.isEmpty(pattern)) {
            pattern = NORMAL_PATTERN;// ww  w.j a  v a2 s  .  co m
        }
        SimpleDateFormat formatter = new SimpleDateFormat(pattern);
        Date curDate = calendar.getTime();
        String str = formatter.format(curDate);
        return str;
    }
}

Related

  1. getAsString(Calendar date)
  2. formatCalendar(Calendar calendar)
  3. formatCalendar(Calendar calendar, String pattern)
  4. formatDateTime(Calendar dateTime)
  5. getLongFriendlyDate(Calendar cal)
  6. getShortFriendlyDate(Calendar cal)