Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.text.SimpleDateFormat;
import java.util.Calendar;

import java.util.GregorianCalendar;

public class Main {
    public static int MIN_YEAR = 1970;

    public static int getDayWeek(int index) {
        int year = MIN_YEAR + index / 12;
        int month = index % 12;
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
        Calendar date = new GregorianCalendar(year, month, 1);
        int dayweek = date.get(Calendar.DAY_OF_WEEK);
        return dayweek;

    }
}