/** * Increments or decrements the specified field and wraps the value of the * field when it goes beyond the maximum or minimum value for the current * date. Other fields will be adjusted as required to maintain a consistent * date. For example, March 31 will roll to April 30 when rolling the month * field. * * @param field * the field to roll. * @param increment * {@code true} to increment the field, {@code false} to * decrement. * @throws IllegalArgumentException * if an invalid field is specified. */ @Override public void roll(int field, boolean increment) { roll(field, increment ? 1 : -1); }
/** * Increments or decrements the specified field and wraps the value of the * field when it goes beyond the maximum or minimum value for the current * date. Other fields will be adjusted as required to maintain a consistent * date. For example, March 31 will roll to April 30 when rolling the month * field. * * @param field * the field to roll. * @param increment * {@code true} to increment the field, {@code false} to * decrement. * @throws IllegalArgumentException * if an invalid field is specified. */ @Override public void roll(int field, boolean increment) { roll(field, increment ? 1 : -1); }
/** * Increments or decrements the specified field and wraps the value of the * field when it goes beyond the maximum or minimum value for the current * date. Other fields will be adjusted as required to maintain a consistent * date. For example, March 31 will roll to April 30 when rolling the month * field. * * @param field the field to roll. * @param increment {@code true} to increment the field, {@code false} to * decrement. * @throws IllegalArgumentException if an invalid field is specified. */ @Override public void roll(int field, boolean increment) { roll(field, increment ? 1 : -1); }
/** * Increments or decrements the specified field and wraps the value of the * field when it goes beyond the maximum or minimum value for the current * date. Other fields will be adjusted as required to maintain a consistent * date. For example, March 31 will roll to April 30 when rolling the month * field. * * @param field * the field to roll. * @param increment * {@code true} to increment the field, {@code false} to * decrement. * @throws IllegalArgumentException * if an invalid field is specified. */ @Override public void roll(int field, boolean increment) { roll(field, increment ? 1 : -1); }
/** * Increments or decrements the specified field and wraps the value of the * field when it goes beyond the maximum or minimum value for the current * date. Other fields will be adjusted as required to maintain a consistent * date. For example, March 31 will roll to April 30 when rolling the month * field. * * @param field * the field to roll. * @param increment * {@code true} to increment the field, {@code false} to * decrement. * @throws IllegalArgumentException * if an invalid field is specified. */ @Override public void roll(int field, boolean increment) { roll(field, increment ? 1 : -1); }
/** * Increments or decrements the specified field and wraps the value of the * field when it goes beyond the maximum or minimum value for the current * date. Other fields will be adjusted as required to maintain a consistent * date. For example, March 31 will roll to April 30 when rolling the month * field. * * @param field * the field to roll. * @param increment * {@code true} to increment the field, {@code false} to * decrement. * @throws IllegalArgumentException * if an invalid field is specified. */ @Override public void roll(int field, boolean increment) { roll(field, increment ? 1 : -1); }
/** * Increments or decrements the specified field and wraps the value of the * field when it goes beyond the maximum or minimum value for the current * date. Other fields will be adjusted as required to maintain a consistent * date. For example, March 31 will roll to April 30 when rolling the month * field. * * @param field * the field to roll. * @param increment * {@code true} to increment the field, {@code false} to * decrement. * @throws IllegalArgumentException * if an invalid field is specified. */ @Override public void roll(int field, boolean increment) { roll(field, increment ? 1 : -1); }
/** * Increments or decrements the specified field and wraps the value of the * field when it goes beyond the maximum or minimum value for the current * date. Other fields will be adjusted as required to maintain a consistent * date. For example, March 31 will roll to April 30 when rolling the month * field. * * @param field * the field to roll. * @param increment * {@code true} to increment the field, {@code false} to * decrement. * @throws IllegalArgumentException * if an invalid field is specified. */ @Override public void roll(int field, boolean increment) { roll(field, increment ? 1 : -1); }
SimpleDateFormat curFormater = new SimpleDateFormat("EEEE, MMMM dd, yyyy"); GregorianCalendar date = new GregorianCalendar(); String[] dateStringArray = new String[7]; for (int day = 0; day < 7; day++) { dateStringArray[day] = curFormater.format(date.getTime()); date.roll(Calendar.DAY_OF_YEAR, true); } setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, dateStringArray));
/** * Method to roll a field by 1. * @param field The field * @param up The whether to move it up */ public void roll(int field, boolean up) { super.roll(field, up); makeDirty(); }
SimpleDateFormat curFormater = new SimpleDateFormat("EEE dd"); GregorianCalendar date = new GregorianCalendar(); String[] dateStringArray = new String[7]; date.set(GregorianCalendar.DATE, date.get(GregorianCalendar.DATE)-date.get(GregorianCalendar.DAY_OF_WEEK)); for (int day = 0; day < 7; day++) { dateStringArray[day] = curFormater.format(date.getTime()); date.setFirstDayOfWeek(day); date.roll(Calendar.DAY_OF_MONTH, true); System.out.println("HELLO WORLD DAYS: " + dateStringArray[day]); } }
/** * Method to roll the value of a field * @param field The field * @param amount The amount to roll by */ public void roll(int field, int amount) { super.roll(field, amount); makeDirty(); }
GregorianCalendar gc= new GregorianCalendar(); gc.setTimeInMillis(System.currentTimeMillis()); gc.roll(GregorianCalendar.DAY_OF_MONTH, true); Date d1 = new Date(); Date d2 = gc.getTime(); SimpleDateFormat sf= new SimpleDateFormat("yyyy-MM-dd"); if(sf.format(d2).hashCode() < sf.format(d1).hashCode()) { System.out.println("date 2 is less than date 1"); } else { System.out.println("date 2 is equal or greater than date 1"); }
@Nonnull public static List<Date> getDaysBetween(@Nonnull final Date start, @Nonnull final Date end) { final List<Date> dates = new ArrayList<Date>(); dates.add(start); Date nextDay = dayAfter(start); while (nextDay.compareTo(end) <= 0) { dates.add(nextDay); } return dates; } @Nonnull public static Date dayAfter(final Date date) { final GregorianCalendar gc = new GregorianCalendar(); gc.setTime(date); gc.roll(Calendar.DAY_OF_YEAR, true); return gc.getTime(); }
assert(dayOfWeekInt >= 1 && dayOfWeekInt <= 7); while(_calendar.get(Calendar.DAY_OF_WEEK) != dayOfWeekInt) { _calendar.roll(Calendar.YEAR, false);
yesterdayCalendar.roll(GregorianCalendar.DAY_OF_YEAR, -1); categories.add(new HistoryDateCategory(HistoryDateStatus.YESTERDAY, yesterdayCalendar, null)); lastWeekCalendar.roll(GregorianCalendar.DAY_OF_YEAR, -7); categories.add(new HistoryDateCategory(HistoryDateStatus.LAST_WEEK, lastWeekCalendar, weekCalendar));
assert(dayOfWeekInt >= 1 && dayOfWeekInt <= 7); while(_calendar.get(Calendar.DAY_OF_WEEK) != dayOfWeekInt) { _calendar.roll(Calendar.YEAR, false);
assert(dayOfWeekInt >= 1 && dayOfWeekInt <= 7); while(_calendar.get(Calendar.DAY_OF_WEEK) != dayOfWeekInt) { _calendar.roll(Calendar.YEAR, false);
super.roll(field, amount); lastSetChinese = false; areChineseFieldsComputed = false;
public void init() { setBackground(Color.pink); setLayout(new GridLayout(3,2)); add(new Label("Dest. Country:", Label.RIGHT)); add(destChooser = new Choice()); destChooser.add("ca"); destChooser.select(0); destChooser.add("sv"); destChooser.add("uk"); destChooser.add("us"); add(new Label("Waybill #", Label.RIGHT)); add(numField = new TextField(12)); numField.addActionListener(handler); add(new Label()); // filler, for grid add(goButton = new Button("Go for it!")); goButton.addActionListener(handler); gc.roll(Calendar.DAY_OF_MONTH, false); // yesterday shipDate = // mmddyy format nf.format(gc.get(Calendar.MONTH)+1) + /* zero-based */ nf.format(gc.get(Calendar.DAY_OF_MONTH)) + nf.format(gc.get(Calendar.YEAR)%100); } }