Java DateFormatSymbols get day of week name String

Description

Java DateFormatSymbols get day of week name String

import java.text.DateFormatSymbols;
import java.util.Calendar;

public class Main {

  public static void main(String[] args) {
    Calendar gCal = Calendar.getInstance();

    int dayOfWeek = gCal.get(Calendar.DAY_OF_WEEK);

    // Create new DateFormatSymbols instance to obtain 
    //the String value for dates
    DateFormatSymbols symbols = new DateFormatSymbols();
    String[] days = symbols.getWeekdays();
    System.out.println(days[dayOfWeek]);

  }/*from   w w w  .  j  av  a  2 s  .c o  m*/
}



PreviousNext

Related