码迷,mamicode.com
首页 > 其他好文 > 详细

打印日历

时间:2018-07-29 16:32:08      阅读:171      评论:0      收藏:0      [点我收藏+]

标签:string   static   ring   span   col   oid   lda   oda   str   

 
 1 import java.io.IOException;
 2 import java.time.DayOfWeek;
 3 import java.time.LocalDate;
 4 
 5 public class test {
 6     public static void main(String[] args) throws IOException {
 7     LocalDate date = LocalDate.now();
 8 
 9     int month = date.getMonthValue();
10     int today = date.getDayOfMonth();
11 
12     date = date.minusDays(today-1);//得到today-1天前的日期
13     DayOfWeek weekday = date.getDayOfWeek();
14     int value = weekday.getValue();
15 
16     System.out.println("Mon Tue Wed Thu Fri Sat Sun");
17     for(int i =1;i<value; i++)
18         System.out.print("    ");
19 
20     while(date.getMonthValue()==month) {
21         System.out.printf("%3d", date.getDayOfMonth());
22         if (date.getDayOfMonth() == today)
23             System.out.print("*");
24         else
25             System.out.print(" ");
26         date = date.plusDays(1);
27         if (date.getDayOfWeek().getValue() == 1)
28             System.out.println();
29     }
31     }
32 }

2018-07-29 14:39:35

打印日历

标签:string   static   ring   span   col   oid   lda   oda   str   

原文地址:https://www.cnblogs.com/confusion/p/9385307.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!