Java Year Week getYmd(int year, int week, int days)

Here you can find the source of getYmd(int year, int week, int days)

Description

get Ymd

License

Open Source License

Declaration

public static String getYmd(int year, int week, int days) 

Method Source Code

//package com.java2s;
/*//from w  ww . ja  v  a  2  s  . c  o m
 * @(#)DateHelper.java        Dec 31, 2012
 * 
 * Copyright (c) 2012 TH(ThreeHelp) Software Studio All rights reserved.
 *
 * This software is the confidential and proprietary information of TH(ThreeHelp) Software Studio
 * You shall not disclose such Confidential Information 
 * and shall use it only in accordance with the terms of the license agreement 
 * you entered into with TH(ThreeHelp) Software Studio
 *
 */

import java.util.Calendar;

public class Main {

    public static String getYmd(int year, int week, int days) {

        Calendar calendar = Calendar.getInstance();
        if (year > 0) {
            calendar.set(Calendar.YEAR, year);
        }
        calendar.set(Calendar.WEEK_OF_YEAR, week);
        calendar.set(Calendar.DAY_OF_WEEK, days);
        int month = calendar.get(Calendar.MONTH) + 1;
        int day = calendar.get(Calendar.DAY_OF_MONTH);
        String ymd = calendar.get(Calendar.YEAR) + "";
        if (month < 10) {
            ymd += "0" + month;
        } else {
            ymd += month;
        }
        if (day < 10) {
            ymd += "0" + day;
        } else {
            ymd += day;
        }

        return ymd;
    }
}

Related

  1. getNextWeekMonday(int year, int weekOfYear)
  2. getNumberOfWeeksInYear(int year)
  3. getSeasonStartWeekOffset(int year)
  4. getStartDayOfWeekNo(int year, int weekNo)
  5. getTotalWeekOfYear(int year)