赞
踩
/** * @param date string 转日期 * @return */ public static Date transBackDate(String date) { Date parse = new Date(); try { if (date=="" || date.equals("0") || date.equals(null) || date.equals("null")){ return format.parse("19700101"); } Date date1 = format.parse(date); long time = date1.getTime(); long newTime = time + 5 * 24 * 60 * 60 * 1000; Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(newTime); Integer year = calendar.get(Calendar.YEAR); Integer month = calendar.get(Calendar.MONTH) + 1; String monthString = ""; String dayString = ""; if (month < 10) { monthString = "0" + month.toString(); } else { monthString = month.toString(); } Integer day = (calendar.get(Calendar.DATE)); if (day < 10) { dayString = "0" + day.toString(); } else { dayString = day.toString(); } StringBuilder sbVar1 = new StringBuilder(); String date2 = sbVar1.append(year).append(monthString).append(dayString).toString(); parse = format.parse(date2); } catch (ParseException e) { e.printStackTrace(); } return parse; }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。