103104105106107108109110
Calendar nowCalendar = Calendar.getInstance(); Calendar cal = Calendar.getInstance(); cal.setTime(myStartDate); cal.set(Calendar.HOUR_OF_DAY, nowCalendar.get(Calendar.HOUR_OF_DAY)); cal.set(Calendar.MINUTE, nowCalendar.get(Calendar.MINUTE)); NSTimestamp now = new NSTimestamp(cal.getTime()); return now; }
123124125126127128129130
cal.setTime(myStartDate); cal.set(Calendar.HOUR_OF_DAY, 9); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); NSTimestamp workStart = new NSTimestamp(cal.getTime()); return workStart; }
139140141142143144145146
cal.setTime(myEndDate); cal.set(Calendar.HOUR_OF_DAY, 18); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); NSTimestamp workEnd = new NSTimestamp(cal.getTime()); return workEnd; }
152153154155156157158
} public Day monthsAgo(int months) { Calendar cal = startCalendar(); cal.add(Calendar.MONTH, -1 * months); return new Day(new NSTimestamp(cal.getTime())); }
158159160161162163164
} public Day monthsFromNow(int months) { Calendar cal = startCalendar(); cal.add(Calendar.MONTH, months); return new Day(new NSTimestamp(cal.getTime())); }
164165166167168169170
} public Day yearsAgo(int years) { Calendar cal = startCalendar(); cal.add(Calendar.YEAR, -1 * years); return new Day(new NSTimestamp(cal.getTime())); }
170171172173174175176
} public Day yearsFromNow(int years) { Calendar cal = startCalendar(); cal.add(Calendar.YEAR, 1 * years); return new Day(new NSTimestamp(cal.getTime())); }
176177178179180181182
} public Day daysAgo(int days) { Calendar cal = startCalendar(); cal.add(Calendar.DATE, -1 * days); return new Day(new NSTimestamp(cal.getTime())); }
182183184185186187188
} public Day daysFromNow(int days) { Calendar cal = startCalendar(); cal.add(Calendar.DATE, days); return new Day(new NSTimestamp(cal.getTime())); }
209210211212213214215
public Day weeksAgo(int weeks) { int days = weeks * 7; Calendar cal = startCalendar(); cal.add(Calendar.DATE, -1 * days); return new Day(new NSTimestamp(cal.getTime())); }