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 {

    public static int getCurWeekNum() {
        Calendar c = Calendar.getInstance();
        c.setTime(new Date(System.currentTimeMillis()));
        int currentDayOfYear = c.get(Calendar.DAY_OF_YEAR) - 5;
        int distanceday;
        if (currentDayOfYear > 56 && currentDayOfYear < 244) {
            distanceday = currentDayOfYear - 56;
        } else if (currentDayOfYear > 244) {
            distanceday = currentDayOfYear - 244;
        } else {
            return 0;
        }
        return distanceday / 7 + 1;
    }
}