• JAVA获取当前年份,月份、日期、小时、分钟、秒等


     import java.util.Calendar;

    public class Main {
        public static void main(String[] args) {
            Calendar cal = Calendar.getInstance();
            int day = cal.get(Calendar.DATE);
            int month = cal.get(Calendar.MONTH) + 1;
            int year = cal.get(Calendar.YEAR);
            int dow = cal.get(Calendar.DAY_OF_WEEK);
            int dom = cal.get(Calendar.DAY_OF_MONTH);
            int doy = cal.get(Calendar.DAY_OF_YEAR);
    int hour = cal.get(Calendar.HOUR_OF_DAY);
    int minute = cal.get(Calendar.MINUTE);
    int second = calendar.get(Calendar.SECOND);
    System.out.println(
    "当期时间: " + cal.getTime()); System.out.println("日期: " + day); System.out.println("月份: " + month); System.out.println("年份: " + year); System.out.println("一周的第几天: " + dow); // 星期日为一周的第一天输出为 1,星期一输出为 2,以此类推 System.out.println("一月中的第几天: " + dom); System.out.println("一年的第几天: " + doy);
    System.out.println("小时: " + hour);
    System.out.println("分钟: " + minute );
    System.out.println("秒: " + second );
    } }
    
    

     

  • 相关阅读:
    [POI2014]FarmCraft
    [POI2014]Solar Panels
    Luogu P2824 [HEOI2016/TJOI2016]排序
    CF903G Yet Another Maxflow Problem
    CF901C Bipartite Segments
    CF749E Inversions After Shuffle
    ARC068C Snuke Line
    BZOJ3747 [POI2015]Kinoman
    SA-IS
    简单字符串
  • 原文地址:https://www.cnblogs.com/pxblog/p/12711616.html
Copyright © 2020-2023  润新知