Home > php教程 > php手册 > java判断是否为下午或上午

java判断是否为下午或上午

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-01 09:46:42
Original
2103 people have browsed it
<code class="language-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");
    }
}</code>
Copy after login

 

Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
Install JAVA
From 1970-01-01 08:00:00
0
0
0
Unable to install java
From 1970-01-01 08:00:00
0
0
0
Can java be used as the backend of the web?
From 1970-01-01 08:00:00
0
0
0
Is this in Java language?
From 1970-01-01 08:00:00
0
0
0
Help: JAVA encrypted data PHP decryption
From 1970-01-01 08:00:00
0
0
0
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template