今天学习了数据结构的栈,然后上了马克思基本原理,接着下午上了英语课,上课学会了十个单词。
然后在网上学习了Java web的课程。然后学习了一下写一个倒计时的代码。
public class CountdownTime { public static void main(String[] args) { LocalDateTime startTime = LocalDateTime.now(); LocalDateTime endTime = startTime.plusMinutes(30); // 设置倒计时结束时间 while (LocalDateTime.now().isBefore(endTime)) { LocalDateTime currentTime = LocalDateTime.now(); Duration remainingTime = Duration.between(currentTime, endTime); long minutes = remainingTime.toMinutes(); long seconds = remainingTime.minusMinutes(minutes).getSeconds(); System.out.printf("倒计时:%02d:%02d\n", minutes, seconds); try { Thread.sleep(10000); // 等待10秒钟 } catch (InterruptedException e) { e.printStackTrace(); } } System.out.println("倒计时结束!"); } }
标签:now,19,2023,天气,倒计时,remainingTime,LocalDateTime,endTime,minutes From: https://www.cnblogs.com/Christmas77/p/17715950.html