zoukankan      html  css  js  c++  java
  • Calendar

    import java.util.Calendar;
    /*Calendar类:
     * public int get(int field)  返回给定日历字段的值。
     * public static Calendar getInstance()  使用默认时区和语言环境获得一个日历。
     * 返回的 Calendar 基于当前时间,使用了默认时区和默认语言环境。
     *
     *  abstract  void add(int field, int amount)
              根据日历的规则,为给定的日历字段  添加或减去  指定的时间量。
        void set(int year, int month, int date)
              设置日历字段 YEAR、MONTH 和 DAY_OF_MONTH 的值。 
     */
    public class CalendarDemo1 {
     public static void main(String[] args) {
      // 返回 Calendar 基于当前时间
      Calendar now = Calendar.getInstance(); // 返回子类对象
      // 获取年
      int year = now.get(Calendar.YEAR);
      // 获取月
      int month = now.get(Calendar.MONTH);
      // 获取天
      int day = now.get(Calendar.DATE);
      System.out.println(year + "年" + month + "月" + day + "日"); // 因为month从0开始
      System.out.println("*************************");
      
      now.add(Calendar.YEAR, -5);
      year = now.get(Calendar.YEAR);
      month = now.get(Calendar.MONTH);
      day = now.get(Calendar.DATE);
      System.out.println(year + "年" + month + "月" + day + "日");
      System.out.println("*************************");
      now.set(22, 22,34);
      year = now.get(Calendar.YEAR);
      month = now.get(Calendar.MONTH);
      day = now.get(Calendar.DATE);
      System.out.println(year + "年" + month + "月" + day + "日");
     }
    }
  • 相关阅读:
    设置五大类型MySQL参数
    php/mysql方法函数
    生成ASP.NET WEB SERVICE代理类
    c#中使用json
    Enterprise Library DataAccess(数据层)笔记
    动态加载并获取usercontrol生成的html
    可能用得上的jquery 插件
    Enterprise Library Cache(缓存程序块)笔记
    ASP.NET中采用HTML控件File进行多文件上传
    windows server 2003 企业版IIS6上配置asp.net4.0网站
  • 原文地址:https://www.cnblogs.com/rong123/p/9887407.html
Copyright © 2011-2022 走看看