zoukankan      html  css  js  c++  java
  • Calendar的用法

    package test;
    
    
    import java.math.BigDecimal;
    import java.nio.channels.NonReadableChannelException;
    import java.text.DateFormat;
    import java.text.SimpleDateFormat;
    import java.util.*;
    
    public class Main {
    
    	private static final String space_operator = " ";
    	private static final double pi = Math.PI;
    	public static void main(String[] args) throws Exception {
    
    		/**
    		 * 直接用Calendar的静态方法获取它的年月日和星期
    		 * month是加上1,因为直接获取是0-11
    		 * week星期日是1,没有0;
    		 */
    		
    		Calendar c = Calendar.getInstance();
    		
    		int year = c.get(Calendar.YEAR);
    		int month = c.get(Calendar.MONTH) + 1;
    		int day = c.get(Calendar.DAY_OF_MONTH);
    		int week = c.get(Calendar.DAY_OF_WEEK);
    	
    		System.out.println(year + "年" + month + "月" + day +  "日" + getweek(week));
    		
    		
    		
    		
    	}
    	public static String getweek(int week) {
    		String [] weeks = {"","星期日","星期一","星期二","星期三","星期四","星期五","星期六"};
    				
    		return weeks[week];
    	}
    	
    }
    

      

  • 相关阅读:
    创建内核对象的专有命名空间
    内核对象句柄表
    Windows小知识(二)
    内核对象与用户对象/GDI对象
    Windows小知识(一)
    Windows中查看错误
    handle(句柄)
    VC中调用其它程序
    消息映射的转变
    实验6.配置链路聚合
  • 原文地址:https://www.cnblogs.com/WINDZLY/p/11788742.html
Copyright © 2011-2022 走看看