import java.time.LocalTime; public class Hello { public static void main(String[] args) { LocalTime now = LocalTime.now(); int hour = now.getHour(); if (hour >= 6 && hour < 8) { System.out.println("早上好"); } else if (hour >= 8 && hour < 12) { System.out.println("上午好"); } else if (hour >= 12 && hour < 14) { System.out.println("中午好"); } else if (hour >= 14 && hour < 18) { System.out.println("下午好"); } else { System.out.println("晚上好"); } } }
标签:语句,hour,System,else,问候,时间,&&,println,out From: https://www.cnblogs.com/liang9479/p/17169582.html