属性编辑器

//String---->Date

import java.text .*;
 import java.util .*;

    public class properity {
        public static void main(String args[]) {
            String strDate = "2019-7-12 18:04:30";
            SimpleDateFormat sDT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            try {
                Date date = sDT.parse(strDate);
                //Fri Jul 12 18:04:30 CST 2019
                System.out.println(date);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

//Date-->String

import java.text .*;
 import java.util .*;

    public class properity {
        public static void main(String args[]) {
            Date date = new Date();
            SimpleDateFormat sDT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            String sdate = sDT.format(date);
            //2019-07-12 18:24:25
            System.out.println(sdate);
        }
    }

 

 

你可能感兴趣的:(java)