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 {
    private static final Calendar calendar = Calendar.getInstance();

    public static Date buildShiftEndTime(int startHour, int startMin, int startAmPm, int endHour, int endMin,
            int endAmPm) {
        endHour = endHour == 12 ? 0 : endHour;

        calendar.clear();

        calendar.set(Calendar.HOUR, endHour);
        calendar.set(Calendar.MINUTE, endMin);

        calendar.set(Calendar.AM_PM, endAmPm);

        if (startAmPm == Calendar.PM && endAmPm == Calendar.AM) {
            calendar.add(Calendar.DAY_OF_MONTH, 1);
        }

        return calendar.getTime();
    }
}