Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.util.Calendar;
import java.util.Date;

public class Main {
    private static Date getStartWeekOfMonth(int year, int month) {
        Calendar c = Calendar.getInstance();
        c.set(year, month - 1, 1);
        int week = c.get(Calendar.DAY_OF_WEEK);
        return getDistanceDate(c.getTime(), 1 - week);
    }

    private static Date getDistanceDate(Date date, int day) {
        Calendar cal = Calendar.getInstance();
        cal.setTime(date);
        cal.add(Calendar.DATE, day);
        return cal.getTime();
    }
}