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.GregorianCalendar;

public class Main {
    static int mDaysByMonth[] = { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 284, 294, 324 };

    static float getDatePlg() {
        Calendar c = new GregorianCalendar();
        int y = c.get(Calendar.YEAR);
        int m = 1 + c.get(Calendar.MONTH);
        int d = c.get(Calendar.DAY_OF_MONTH);
        return getDatePlg(y, m, d);
    }

    static float getDatePlg(int y, int m, int d) {
        int days = 100 * 365 + 24;
        while (y > 2000) {
            days += 365;
            if ((y % 4) == 0)
                ++days;
            --y;
        }
        days += mDaysByMonth[m] + d;
        return days;
    }
}