Tag Archives: C

Java: Parts of the Day

A handy utility method that will return the part of the day, such as morning, afternoon, evening, etc.

public static String getPartOfTheDay(final int hour)
{
    if(hour > 4 && hour < 12)
    {
        if(hour <= 8)
        {
            return "Early Morning";
        }
        else if(hour > 8 && hour < 11)
        {
            return "Morning";
        }
 
        return "Late Morning";        
    }
    else if(hour >= 12 && hour < 17)
    {
        if(hour >= 13 && hour <= 15)
        {   
            return "Early Afternoon";
        }
        else if(hour >= 16)
        {
            return "Late Afternoon";
        }
 
        return "Afternoon";
    }
    else if(hour >= 17 && hour <= 21)
    {
        if(hour <= 19)
        {   
            return "Early Evening";
        }
 
        return "Evening";
    }
    else
    {
        return "Night";
    }
}

The method is based on the following logic, that many people would agree with:

Morning: 5 to 12

  • Early morning: 5 to 8
  • Late morning: 11 to 12

Afternoon: 12 to 17

  • Early afternoon: 13 to 15
  • Late afternoon: 16 to 17

Evening: 17 to 21

  • Early evening: 17 to 21

Night: 21 to 4

vHash

vHash is small Windows utility for generating hashes using various cryptography providers and algorithms that they support such as MD-5, SHA-1, etc. It’s written on C using Win32 API making it light and dependency free.

Currently the utility does not support keyed hash algorithms such as HMAC or MAC. Also the program is Unicode.

vHash

Downloads and more information are available on the vHash project page.