您的位置:首页 > 其它

LocalTime的使用方法

2017-11-22 19:17 190 查看
package date;

import java.time.LocalTime;

public class LocalTimeTest {

/**
*
* @param args
*/
public static void main(String[] args) {

LocalTime rightNow=LocalTime.now();
LocalTime bedTime=LocalTime.of(22, 10);
System.out.println(rightNow);
System.out.println(bedTime);
LocalTime wakeUp=bedTime.plusHours(10);
bedTime.plusMinutes(10);
bedTime.plusSeconds(10);
bedTime.minusHours(1);
bedTime.minusMinutes(1);
bedTime.minusSeconds(1);

LocalTime time=bedTime.parse("10:10:10");
LocalTime time1=bedTime.withHour(12);
LocalTime time2=bedTime.withMinute(12);
LocalTime time3=bedTime.withSecond(12);
System.out.println(time1);
System.out.println(time2);
System.out.println(time3);

long hour=rightNow.getHour();
long minute=rightNow.getMinute();
long second=rightNow.getSecond();
System.out.println(hour+"  "+minute+"  "+second);

System.out.println(rightNow.isBefore(bedTime));

System.out.println(rightNow.isAfter(bedTime));
}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  LocalTime jar 1.8