码迷,mamicode.com
首页 > 数据库 > 详细

accessor method & mutator method

时间:2016-12-13 06:43:34      阅读:272      评论:0      收藏:0      [点我收藏+]

标签:val   log   style   today   int   date   now()   amp   ring   

import java.time.*;

public class MyTest{
    public static void main(String[] args){
        LocalDate date = LocalDate.now();
        int month = date.getMonthValue();
        int today = date.getDayOfMonth();

        date = date.minusDays(today - 1);
        DayOfWeek weekday = date.getDayOfWeek();
        int value = weekday.getValue();

        System.out.println("Mon Tue Wed Thu Fri Sat Sun");
        for(int i = 1; i < value; i ++)
            System.out.print("    ");
        while(date.getMonthValue() == month){
            System.out.printf("%3d", date.getDayOfMonth());
            if(date.getDayOfMonth() == today)
                System.out.print("*");
            else
                System.out.print(" ");
            date = date.plusDays(1);
            if(date.getDayOfWeek().getValue() == 1) System.out.println();
        }
        if(date.getDayOfWeek().getValue() != 1) System.out.println();
    }
}
 date = date.minusDays(today - 1); 更改了 date 所引用的对象

accessor method & mutator method

标签:val   log   style   today   int   date   now()   amp   ring   

原文地址:http://www.cnblogs.com/xkxf/p/6166324.html

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