is Day time - Android java.util

Android examples for java.util:Calendar

Description

is Day time

Demo Code


//package com.java2s;

import java.util.Calendar;

public class Main {
    public static boolean isDay() {
        Calendar c = Calendar.getInstance();
        int timeOfDay = c.get(Calendar.HOUR_OF_DAY);
        return timeOfDay >= 6 && timeOfDay < 20;
    }//from  w w w .ja va  2s  . c o m

    public static boolean isDay(long now) {
        Calendar c = Calendar.getInstance();
        c.setTimeInMillis(now);
        int timeOfDay = c.get(Calendar.HOUR_OF_DAY);
        return timeOfDay >= 6 && timeOfDay < 20;
    }
}

Related Tutorials