get Date Formatted - Android java.util

Android examples for java.util:Date Format

Description

get Date Formatted

Demo Code


//package com.java2s;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;

public class Main {
    public static String getDateFormated(Calendar calendar, String template) {

        SimpleDateFormat dateFormat = new SimpleDateFormat(template,
                Locale.US);//w w w .  j ava2s  . c o m

        return dateFormat.format(calendar.getTime()).toString();

    }

    public static String getDateFormated(Date date, String template) {

        SimpleDateFormat dateFormat = new SimpleDateFormat(template,
                Locale.US);

        return dateFormat.format(date).toString();

    }
}

Related Tutorials