问题背景:想把一个时间直接转成字符串格式 通过查api发现有个toLocaleString(),根据本地时间格式,把 Date 对象转换为字符串 new Date().toLocaleString(); //"2018/5/31 下午1:43:06" 但是默认是12小时制,会带这种上午下午,所以肯定不需要,继续查,发现可以配置 ; (new Date(ss).toLocaleString('chinese',{hour12:false})).replace(/\//g,'-'); //…
java转换成秒数 Date类有一个getTime()可以换回秒数,例如: public class DateToSecond { public static void main(String[] args) { Date date = new Date(System.currentTimeMillis()); System.out.println(date.getTime()); } } 或者直接使用long类型存储毫秒数, long base = System.currentTimeMill…