format Date as year/month/day format - Android java.util

Android examples for java.util:Year

Description

format Date as year/month/day format

Demo Code

import android.text.TextUtils;
import android.widget.TextView;
import java.util.Calendar;

public class Main{

    public static String formatDate(int year, int monthOfYear,
            int dayOfMonth) {
        return year + "/" + monthOfYear + "/" + dayOfMonth;
    }/* www .  j  a  v  a2  s  .  c om*/
    public static String formatDate(Calendar calendar) {
        return formatDate(calendar.get(Calendar.YEAR),
                calendar.get(Calendar.MONTH) + 1,
                calendar.get(Calendar.DAY_OF_MONTH));
    }

}

Related Tutorials