Javaコードは、今年の最初の数日間、今月、今週、現在の時刻を取得します

  公共の 静的な 無効getWeekMonthYear(){ 
        地図 <文字列、整数> mapInt = 新しいのLinkedHashMap <文字列、整数> (); 
        カレンダーカレンダー = Calendar.getInstance(); 
        日付今日 = 新しい日付(); 
        calendar.setTime(今日)。// 此处可换为具体某一时间
        int型平日= calendar.get(Calendar.DAY_OF_WEEKの);
        INT MONTHDAY = calendar.get(Calendar.DAY_OF_MONTH)。
        INT yearDay = calendar.get(Calendar.DAY_OF_YEAR)。
        もし(平日== 1 ){
            平日 = 7 
        } { 
            平日 =平日- 1 
        } 
        mapInt.put( "周" 、平日)。
        mapInt.put( "月" 、MONTHDAY)。
        mapInt.put( "年" 、yearDay)。
        (のMap.Entry <文字列、整数> エントリ:mapInt.entrySet()){ 
            するSystem.out.println( "今天是本" + entry.getKey()+ "的第" + entry.getValue()+「天" ); 
        } 
    }

 

おすすめ

転載: www.cnblogs.com/52KT9/p/12527001.html