Java Utililty Methods Calendar Add

List of utility methods to do Calendar Add

Description

The list of methods to do Calendar Add are organized into topic(s).

Method

voidappendEra(StringBuffer sb, Calendar cal)
append Era
if (cal.get(Calendar.ERA) == GregorianCalendar.BC) {
    sb.append(" BC");
voidappendTime(Calendar value, StringBuffer dateString)
append Time
if (value.get(Calendar.HOUR_OF_DAY) < 10) {
    dateString.append("0");
dateString.append(value.get(Calendar.HOUR_OF_DAY)).append(":");
if (value.get(Calendar.MINUTE) < 10) {
    dateString.append("0");
dateString.append(value.get(Calendar.MINUTE)).append(":");
...
voidappendTimeZone(Calendar calendar, StringBuffer dateString)
append Time Zone
int timezoneOffSet = calendar.get(Calendar.ZONE_OFFSET) + calendar.get(Calendar.DST_OFFSET);
int timezoneOffSetInMinits = timezoneOffSet / 60000;
if (timezoneOffSetInMinits < 0) {
    dateString.append("-");
    timezoneOffSetInMinits = timezoneOffSetInMinits * -1;
} else {
    dateString.append("+");
int hours = timezoneOffSetInMinits / 60;
int minits = timezoneOffSetInMinits % 60;
if (hours < 10) {
    dateString.append("0");
dateString.append(hours).append(":");
if (minits < 10) {
    dateString.append("0");
dateString.append(minits);
CalendarcloneAndAdd(Calendar source, int field, int amount)
clone And Add
Calendar r = (Calendar) source.clone();
r.add(field, amount);
return r;
CalendargetDayOfAddDay(final Calendar calendar, final int day)
get Day Of Add Day
Calendar cln = Calendar.getInstance();
cln.setTimeInMillis(calendar.getTimeInMillis());
cln.add(Calendar.DAY_OF_MONTH, day);
return cln;
CalendargetStartDateForLogQuery(int calendarField, int amountToAdd)
get Start Date For Log Query
Calendar startDate = Calendar.getInstance();
startDate.set(Calendar.HOUR_OF_DAY, 0);
startDate.set(Calendar.MINUTE, 0);
startDate.set(Calendar.SECOND, 0);
startDate.set(Calendar.MILLISECOND, 0);
startDate.add(calendarField, amountToAdd);
return startDate;
GregorianCalendargetWithDaysAdded(GregorianCalendar originalDate, int days)
Returns a new GregorianCalendar instance that is the specified value plus the specified number of days added.
GregorianCalendar newDate = (GregorianCalendar) originalDate.clone();
newDate.add(Calendar.DAY_OF_MONTH, days);
return newDate;
voidmoveToCalendarSecondJustAdded(Calendar cal, int seconds)
move To Calendar Second Just Added
addCalendarSecond(cal, seconds);
moveToCalendarSecondJust(cal);