Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Mozilla Public License 

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

import java.util.Locale;

public class Main {
    public static final ArrayList<String> sDayAbbreviations = new ArrayList<>();
    public static final ArrayList<String> sDayNames = new ArrayList<>();
    public static final SimpleDateFormat dayLabelFormatter = new SimpleDateFormat("EE M/d", Locale.US);
    public static final SimpleDateFormat dayAbbrevFormatter = new SimpleDateFormat("M/d", Locale.US);

    private static void populateDayRanges(Date start, Date end) {
        Calendar startCal = Calendar.getInstance();
        startCal.setTime(start);
        Calendar endCal = Calendar.getInstance();
        endCal.setTime(end);

        sDayNames.clear();
        sDayAbbreviations.clear();

        for (Date date = startCal.getTime(); startCal.before(endCal); startCal.add(Calendar.DATE,
                1), date = startCal.getTime()) {
            sDayNames.add(dayLabelFormatter.format(date));
            sDayAbbreviations.add(dayAbbrevFormatter.format(date));
        }
    }
}