Here you can find the source of timestampPlusDay2DDMMYYYY(java.sql.Timestamp ts, int iDayPlus)
Parameter | Description |
---|---|
ts | a parameter |
iDayPlus | number of day to add |
public static String timestampPlusDay2DDMMYYYY(java.sql.Timestamp ts, int iDayPlus)
//package com.java2s; public class Main { /**//from w ww . j a va 2 s . co m * return string dd/mm/yyyy from a Timestamp + a addtional day * @param ts * @param iDayPlus number of day to add * @return */ public static String timestampPlusDay2DDMMYYYY(java.sql.Timestamp ts, int iDayPlus) { if (ts == null) { return ""; } java.util.Calendar calendar = java.util.Calendar.getInstance(); calendar.setTime(new java.util.Date(ts.getTime())); int iDay = calendar.get(calendar.DAY_OF_MONTH); calendar.set(calendar.DAY_OF_MONTH, iDay + iDayPlus); java.sql.Timestamp tsNew = new java.sql.Timestamp((calendar.getTime()).getTime()); return Timestamp2DDMMYYYY(tsNew); } public static String Timestamp2DDMMYYYY(java.sql.Timestamp ts) { if (ts == null) { return ""; } else { java.util.Calendar calendar = java.util.Calendar.getInstance(); calendar.setTime(new java.util.Date(ts.getTime())); String strTemp = Integer.toString(calendar.get(calendar.DAY_OF_MONTH)); if (calendar.get(calendar.DAY_OF_MONTH) < 10) { strTemp = "0" + strTemp; } if (calendar.get(calendar.MONTH) + 1 < 10) { return strTemp + "/0" + (calendar.get(calendar.MONTH) + 1) + "/" + calendar.get(calendar.YEAR); } else { return strTemp + "/" + (calendar.get(calendar.MONTH) + 1) + "/" + calendar.get(calendar.YEAR); } } } }