标签:
本文章向大家介绍java如何实现判断时间是否为下午或上午,感兴趣的码农可以参考一下,请看下面代码:
import org.junit.Test; /** * 测试当前时间是否为下午或上午 * @author pamgo * */ public class CalendarT { @Test public void testTodayPMorAM(){ int i = Calendar.getInstance(Locale.US).get(Calendar.AM_PM); System.out.println(i == Calendar.PM ? "pm":"am"); } @Test public void testTodayPMorAM2(){ boolean isPM = Calendar.getInstance().get(Calendar.HOUR_OF_DAY) >= 12; System.out.println(isPM ? "YES":"NO"); }
原文地址:http://www.manongjc.com/article/536.html
其他文章:
标签:
原文地址:http://www.cnblogs.com/manongjc/p/5339417.html