package wb; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static void main(String[] args) throws ParseException { String time1="2021-12-17 12:01:46"; String time2="2021-12-17 12:01:47"; SimpleDateFormat tempDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Date date1=tempDate.parse(time1); Date date2=tempDate.parse(time2); long result=date2.getTime()-date1.getTime(); System.out.println("差值:"+result); } }
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)