修改日期格式为年月日时分秒: alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss';select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') as nowTime from dual; //日期转化为年月日时分秒格式select to_char(sysdate,'yyyy') nowYear from dual; //获取时间的年select to_char(sysdate,'mm'
Date d = new Date(); System.out.println(d); //Sat Mar 16 20:58:56 CST 2019 System.out.println(d.toLocaleString());//2019-3-16 20:59:38 System.out.println(new SimpleDateFormat("yyyy-MM-dd ahh:mm:ss").format(d));//2019-3-16 下午20:59:38 当使用 toLocale
Date ruZhi = new Date("入职年月bai"); Date now = new Date(); //算出du来时间夸格zhi多长 long shiChang = now.getTime()-now.getTIme(); //转换成天 int day = shiChang/(1000*60*24); //转换成想要dao的格式,这里zhuan定为1年=365天 1月=30天 //算出年 int year =day/365; day = day%365; //算出月 in