Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

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

public class Main {
    public static void main(String[] args) {
        Calendar calendar = Calendar.getInstance();

        // 15-04-2012
        calendar.set(Calendar.DAY_OF_MONTH, 15);
        calendar.set(Calendar.YEAR, 2012);
        calendar.set(Calendar.HOUR, 0);
        calendar.set(Calendar.MINUTE, 0);
        calendar.set(Calendar.SECOND, 0);
        calendar.set(Calendar.MONTH, 3);
        Date start = calendar.getTime();

        // 15-06-2012
        calendar.set(Calendar.MONTH, 5);
        Date end = calendar.getTime();

        calendar.setTime(start);
        Date d = null;
        while ((d = calendar.getTime()).before(end) || d.equals(end)) {
            int day = calendar.get(Calendar.DAY_OF_WEEK);
            if (day != Calendar.SATURDAY && day != Calendar.SUNDAY) {
                System.out.println(d);
            }
            calendar.add(Calendar.DAY_OF_MONTH, 1);
        }
    }
}