package?ojama; ? import?java.text.SimpleDateFormat; import?java.util.Date; ? public?class?Test?{ public?static?void?main(String[]?args)?throws?Throwable?{ SimpleDateFormat?format?=?new?SimpleDateFormat("yyyyMMddHHmmss"); Date?parse?=?format.parse("20180321141111"); Date?date?=?format.parse("20180321141111"); long?between?=?date.getTime()?-?parse.getTime(); long?day?=?between?/?(24?*?60?*?60?*?1000); long?hour?=?(between?/?(60?*?60?*?1000)?-?day?*?24); long?min?=?((between?/?(60?*?1000))?-?day?*?24?*?60?-?hour?*?60); long?s?=?(between?/?1000?-?day?*?24?*?60?*?60?-?hour?*?60?*?60?-?min?*?60); System.out.println(day?+?"天"?+?hour?+?"小时"?+?min?+?"分"?+?s?+?"秒"); } }
?
原文:https://blog.51cto.com/u_4955660/2847480