Format date in MM / dd/ YYYY format - Android java.util

Android examples for java.util:Date Format

Description

Format date in MM / dd/ YYYY format

Demo Code

import android.annotation.SuppressLint;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;

public class Main{

    public static String date2MMddWeek(Date date) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);//from  ww  w.  j  ava 2s .c o m
        int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK);
        return new SimpleDateFormat("MM / dd/ YYYY").format(date)
                + WEEK[dayOfWeek - 1];
    }

}

Related Tutorials