zoukankan      html  css  js  c++  java
  • java 获取当前时间的年份、月份、周数

    java 获取当前时间的年份、月份、周数

    import java.text.SimpleDateFormat;
    import java.util.Calendar;
    public class testCal {
        public static void main(String[] args) {
            Calendar c = Calendar.getInstance();
            String getCurrentTime=new SimpleDateFormat("yyyy-MM-dd ").format(c.getTime());
            System.out.println(getCurrentTime);//年-月-日
            String getCurrent1=new SimpleDateFormat("yyyy-MM ").format(c.getTime());
            System.out.println(getCurrent1);//年-月
            System.out.println("当前时间 年-月-日:" + new SimpleDateFormat("yyyy-MM-dd ").format(c.getTime()));
            System.out.println("当前时间 年-月-日 时:分:秒:" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(c.getTime()));
            System.out.println("当前时间的年份:" + c.get(Calendar.YEAR));//获取当前年
            System.out.println("当前时间的月份:" + (c.get(Calendar.MONTH) + 1));
            // 一年内的第xx周//获取当前星期是第几周
            System.out.println("当前时间的年周数:" + c.get(Calendar.WEEK_OF_YEAR));
    }
    }

  • 相关阅读:
    JAVA队列的使用
    四种线程池的使用
    JAVA中只有值传递
    为什么说Java语言是平台无关的?
    Jsoup爬虫解析
    java爬虫
    oracle触发器
    easyUi引入方法
    highchart
    July 20th 2017 Week 29th Thursday
  • 原文地址:https://www.cnblogs.com/eosclover/p/15398970.html
Copyright © 2011-2022 走看看