2000字范文,分享全网优秀范文,学习好帮手!
2000字范文 > java判断时间为上午 中午 下午 晚上 凌晨

java判断时间为上午 中午 下午 晚上 凌晨

时间:2020-11-25 22:48:58

相关推荐

java判断时间为上午 中午 下午 晚上 凌晨

public static void main(String[] args) {Date date = new Date();SimpleDateFormat df = new SimpleDateFormat("HH");String str = df.format(date);int a = Integer.parseInt(str);if (a >= 0 && a <= 6) {System.out.println("凌晨");}if (a > 6 && a <= 12) {System.out.println("上午");}if (a > 12 && a <= 13) {System.out.println("中午");}if (a > 13 && a <= 18) {System.out.println("下午");}if (a > 18 && a <= 24) {System.out.println("晚上");}}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。