Get the day of the week from a calendar to a string. - Android java.util

Android examples for java.util:Week

Description

Get the day of the week from a calendar to a string.

Demo Code


//package com.java2s;
import java.text.SimpleDateFormat;

public class Main {
    public static void main(String[] argv) {
        int dayOfWeek = 2;
        System.out.println(convertToDayOfWeekString(dayOfWeek));
    }/*from ww  w  .ja  va 2s.com*/

    /**
     * Get the day of the week from a calendar to a string.
     * @param dayOfWeek The Calendar.DAY_OF_WEEK
     * @return The formatted day of the week
     */
    public static String convertToDayOfWeekString(int dayOfWeek) {
        SimpleDateFormat dayOfWeekFormat = new SimpleDateFormat("EEEE");
        return dayOfWeekFormat.format(dayOfWeek);
    }
}

Related Tutorials