Here you can find the source of getEndDayByWeekOfYear(int year, int weekNo)
Parameter | Description |
---|---|
year | a parameter |
weekNo | a parameter |
public static String getEndDayByWeekOfYear(int year, int weekNo)
//package com.java2s; import java.util.Calendar; public class Main { /**/*from w w w . j av a2s. com*/ * get the end day of given week no of a year.,the first day of week is Sunday * * @param year * @param weekNo * @return */ public static String getEndDayByWeekOfYear(int year, int weekNo) { Calendar cal = getCalendarFormYear(year); cal.set(Calendar.WEEK_OF_YEAR, weekNo); cal.add(Calendar.DAY_OF_WEEK, 6); int monthInt = cal.get(Calendar.MONTH) + 1; String monthString = monthInt < 10 ? "0" + monthInt : monthInt + ""; int dayOfMontyInt = cal.get(Calendar.DAY_OF_MONTH); String dayOfMonth = dayOfMontyInt < 10 ? "0" + dayOfMontyInt : dayOfMontyInt + ""; return cal.get(Calendar.YEAR) + "-" + monthString + "-" + dayOfMonth; } /** * get Calendar of given year * * @param year * @return */ private static Calendar getCalendarFormYear(int year) { Calendar cal = Calendar.getInstance(); cal.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY); cal.set(Calendar.YEAR, year); return cal; } }