Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.util.Calendar;

public class Main {
    public static void main(String[] args) {
        Calendar startEmployment = Calendar.getInstance();
        startEmployment.set(2010, 2, 1);
        startEmployment.set(2011, Calendar.FEBRUARY, 1);

        Calendar now = Calendar.getInstance();

        long numberOfDays1 = countDays(startEmployment, now);

        System.out.println(numberOfDays1);
    }

    private static long countDays(Calendar start, Calendar end) {
        long totalNumberOfDays = 0;
        while (start.before(end)) {
            start.add(Calendar.DAY_OF_MONTH, 1);
            totalNumberOfDays++;
        }
        return totalNumberOfDays;
    }
}