Last active
February 23, 2022 16:19
-
-
Save Ankit-Slnk/648de1b6b980b1b565542e1eca612eda to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static String greeting() { | |
Calendar c = Calendar.getInstance(); | |
int timeOfDay = c.get(Calendar.HOUR_OF_DAY); | |
if (timeOfDay >= 0 && timeOfDay < 12) { | |
return "Good Morning"; | |
} else if (timeOfDay >= 12 && timeOfDay < 16) { | |
return "Good Afternoon"; | |
} else if (timeOfDay >= 16 && timeOfDay < 21) { | |
return "Good Evening"; | |
} else if (timeOfDay >= 21 && timeOfDay < 24) { | |
return "Good Night"; | |
} else { | |
return "Hello"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment