minute Floor - Java java.util

Java examples for java.util:Minute

Description

minute Floor

Demo Code


//package com.java2s;

import java.util.Calendar;

public class Main {
    public static void main(String[] argv) throws Exception {
        Calendar calendar = Calendar.getInstance();
        minuteFloor(calendar);/*from w w w . j a  v a  2 s  . c  o  m*/
    }

    public static void minuteFloor(Calendar calendar) {
        secondFloor(calendar);
        calendar.set(Calendar.SECOND, 0);
    }

    public static void minuteFloor(Calendar calendar, int number) {
        secondFloor(calendar);
        calendar.set(Calendar.SECOND, 0);
        if (number > 1) {
            int minutes = calendar.get(Calendar.SECOND);
            calendar.set(Calendar.SECOND, (minutes / number) * number);
        }
    }

    public static void secondFloor(Calendar calendar) {
        calendar.set(Calendar.MILLISECOND, 0);
    }
}

Related Tutorials