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.GregorianCalendar;

public class Main {
    public static float getPercentOfDay() {
        GregorianCalendar cal = new GregorianCalendar();
        float dayMillis = 0;
        dayMillis += (cal.get(Calendar.HOUR_OF_DAY) * 60 * 60);
        dayMillis += (cal.get(Calendar.MINUTE) * 60);
        dayMillis += cal.get(Calendar.SECOND);
        float totalDayMillis = (24f * 60f * 60f);
        return (dayMillis / totalDayMillis);
    }
}