zoukankan      html  css  js  c++  java
  • java日期操作

    //字符串转日期
        public static void dt7() throws ParseException {
            String str_date="2015---08---08";
            DateFormat dt=new SimpleDateFormat("yyyy--MM--dd");
            Date date=dt.parse(str_date);
            System.out.println(date);
        }
    
        public static void dt6() throws ParseException {
            String str_date="2015年08月08日";
            DateFormat dt=DateFormat.getDateInstance(DateFormat.LONG);
            Date date=dt.parse(str_date);
            System.out.println(date);
        }
    
        public static void da3() throws ParseException {
            String str_date="2015-08-08";
            DateFormat dt=DateFormat.getDateInstance();
            Date date=dt.parse(str_date);
            System.out.println(date);
        }
        
        //日期转字符串
    
        public static void dt3() {
            Date dt=new Date();
            DateFormat dtf=new SimpleDateFormat("yyyy-MM-dd");
            String s=dtf.format(dt);
            System.out.println(s);
        }
    
        public static void dt2() {
            Date dt=new Date();
            DateFormat dtf=DateFormat.getDateInstance(DateFormat.LONG);
            String s=dtf.format(dt);
            System.out.println(s);
        }
    
        public static void cl() {
            long time=System.currentTimeMillis();
            Date dt=new Date(20151440592355603l);
            System.out.print(dt);
            System.out.print(time);
        }
  • 相关阅读:
    未格式化的输入/输出操作
    格式化输入与输出
    随机数
    正则表达式
    bitset
    tuple
    servlet笔记
    springside
    maven
    Lua简易入门教程
  • 原文地址:https://www.cnblogs.com/zywf/p/4761712.html
Copyright © 2011-2022 走看看