1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| public static String newlongdate(int amountDate){ DecimalFormat df = new DecimalFormat("00"); Calendar calendar = Calendar.getInstance(); calendar.add(calendar.DATE, amountDate); String year = Integer.toString(calendar.get(Calendar.YEAR)); String month = df.format(calendar.get(Calendar.MONTH) + 1); String day = df.format(calendar.get(Calendar.DATE)); String hour = ""; if( calendar.get(Calendar.AM_PM) == Calendar.PM){ hour = df.format(calendar.get(Calendar.HOUR)+12); } else { hour = df.format(calendar.get(Calendar.HOUR)); } String minute = df.format(calendar.get(Calendar.MINUTE)); String date = year + month + day + hour + minute; return date; }
|