-
-
Save anandaanv/99689fd609e1342fe1022ed5bc270697 to your computer and use it in GitHub Desktop.
non-testable method, because of uncertainity
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 String getTimeOfDay() { | |
Date time = new Date(); //new Date() will return current time. So the value of it will change in every hour. | |
if (time.getHours() >= 0 && time.getHours() < 6) { | |
return "Night"; | |
} | |
if (time.getHours() >= 6 && time.getHours() < 12) { | |
return "Morning"; | |
} | |
if (time.getHours() >= 12 && time.getHours() < 18) { | |
return "Afternoon"; | |
} | |
return "Evening"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment