Here you can find the source of javaCalendarToNewTimeApi(int dayOfWeek)
Parameter | Description |
---|---|
dayOfWeek | Calendar day of week to convert |
Parameter | Description |
---|---|
IllegalArgumentException | if dayOfWeek is not a constant from Calendar |
public static DayOfWeek javaCalendarToNewTimeApi(int dayOfWeek)
//package com.java2s; //License from project: Apache License import java.time.DayOfWeek; import java.util.Calendar; public class Main { /**/*w w w . ja v a 2s.c o m*/ * The method is intended to convert {@link Calendar} day of week to {@link DayOfWeek}. * * @param dayOfWeek {@link Calendar} day of week to convert * @return {@link DayOfWeek} converted from {@link Calendar} day of week * @throws IllegalArgumentException if dayOfWeek is not a constant from {@link Calendar} */ public static DayOfWeek javaCalendarToNewTimeApi(int dayOfWeek) { switch (dayOfWeek) { case Calendar.MONDAY: return DayOfWeek.MONDAY; case Calendar.TUESDAY: return DayOfWeek.TUESDAY; case Calendar.WEDNESDAY: return DayOfWeek.WEDNESDAY; case Calendar.THURSDAY: return DayOfWeek.THURSDAY; case Calendar.FRIDAY: return DayOfWeek.FRIDAY; case Calendar.SATURDAY: return DayOfWeek.SATURDAY; case Calendar.SUNDAY: return DayOfWeek.SUNDAY; default: throw new IllegalArgumentException("Unknown day of week number: [" + dayOfWeek + "]"); } } }