Java Year Week getStartDayOfWeekNo(int year, int weekNo)

Here you can find the source of getStartDayOfWeekNo(int year, int weekNo)

Description

get start date of given week no of a year

License

Apache License

Parameter

Parameter Description
year a parameter
weekNo a parameter

Declaration

public static String getStartDayOfWeekNo(int year, int weekNo) 

Method Source Code

//package com.java2s;
/**/*from   ww w. j ava2  s. c om*/
 *  Copyright (c) 2012-2014 http://www.eryansky.com
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 */

import java.util.Calendar;

public class Main {
    /**
     * get start date of given week no of a year
     *
     * @param year
     * @param weekNo
     * @return
     */
    public static String getStartDayOfWeekNo(int year, int weekNo) {
        Calendar cal = getCalendarFormYear(year);
        cal.set(Calendar.WEEK_OF_YEAR, weekNo);
        return cal.get(Calendar.YEAR) + "-" + (cal.get(Calendar.MONTH) + 1) + "-" + cal.get(Calendar.DAY_OF_MONTH);

    }

    /**
     * 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;
    }
}

Related

  1. getLastWeekOfYear()
  2. getMaxWeekNumOfYear(int year)
  3. getNextWeekMonday(int year, int weekOfYear)
  4. getNumberOfWeeksInYear(int year)
  5. getSeasonStartWeekOffset(int year)
  6. getTotalWeekOfYear(int year)
  7. getYmd(int year, int week, int days)