Here you can find the source of getDayOfWeekZeroIndexed(Date dateTime)
Parameter | Description |
---|---|
dateTime | to get zero-indexed day of week |
public static int getDayOfWeekZeroIndexed(Date dateTime)
//package com.java2s; import java.util.Calendar; import java.util.Date; public class Main { /**/*ww w . ja va 2 s .c o m*/ * Returns the day of week as zero indexed. * That means, a dateTime in monday will return 0; * * @param dateTime to get zero-indexed day of week * @return zero-indexed day of week */ public static int getDayOfWeekZeroIndexed(Date dateTime) { final Calendar calendar = Calendar.getInstance(); calendar.setTime(dateTime); final int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK); switch (dayOfWeek) { case Calendar.MONDAY: return 0; case Calendar.TUESDAY: return 1; case Calendar.WEDNESDAY: return 2; case Calendar.THURSDAY: return 3; case Calendar.FRIDAY: return 4; case Calendar.SATURDAY: return 5; case Calendar.SUNDAY: return 6; default: throw new IllegalStateException(); } } }