SimpleDateFormat DATETIME_SEC_STR = new SimpleDateFormat("yyyyMMddHHmmss"); SimpleDateFormat DATE_STR = new SimpleDateFormat("yyyyMMdd"); Date busyTime = DATE_STR.parse("20150413"); GregorianCalendar currGcTime15Minute = new GregorianCalendar(); currGcTime15Minute.setTime(busyTime); //当前时间往前推15分钟 currGcTime15Minute.add(Calendar.MINUTE, -15); //转换成yyyyMMddHHmmss格式的long型 long diff15Minute2 = Long.valueOf(DATETIME_SEC_STR.format(currGcTime15Minute.getTime())); System.out.println("diff15Minute2="+diff15Minute2); //分析long数据为yyyyMMdd 或者 HHmmss long yyyyMMdd = 20150411103000l / 1000000; long HHmmss = 20150411103000l % 1000000; System.out.println("年月日=" + yyyyMMdd); System.out.println("时分秒=" + HHmmss);
时间: 2024-11-04 12:23:44