标签:order ati try length ext pop 提醒 for date
项目开发过程中。须要进行订单提醒日期的设置。主要包含设置每月指定的日期或者指定的天数,代码例如以下:
public static String DateOperation(String type, Date myDate, int num) { String date = null; SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd"); try { Calendar c = Calendar.getInstance(); c.setTime(myDate); if (type.equals("0")){ c.add(Calendar.MONTH, 1); myDate = c.getTime(); date = formatter.format(myDate); String dt = date.substring(date.length()-2,date.length()); System.out.println("截取后的日期:[" + dt + "]"); int days = num - Integer.parseInt(dt); System.out.println("相差天数:" + days); c.add(Calendar.DATE, days); myDate = c.getTime(); date = formatter.format(myDate); }else if (type.equals("1")){ c.add(Calendar.DATE, num); myDate = c.getTime(); date = formatter.format(myDate); } System.out.println("订单下次提醒日期:[" + date + "]"); } catch (Exception e1) { e1.printStackTrace(); } return date; }
标签:order ati try length ext pop 提醒 for date
原文地址:http://www.cnblogs.com/slgkaifa/p/6882329.html