/** * Sets the time of this {@code Calendar} to the given Unix time. See {@link Date} for more * about what this means. */ public void setTimeInMillis(long milliseconds) { if (!isTimeSet || !areFieldsSet || time != milliseconds) { time = milliseconds; isTimeSet = true; areFieldsSet = false; complete(); } }
/** * Returns the value of the given field after computing the field values by * calling {@code complete()} first. * * @throws IllegalArgumentException * if the fields are not set, the time is not set, and the * time cannot be computed from the current field values. * @throws ArrayIndexOutOfBoundsException * if the field is not inside the range of possible fields. * The range is starting at 0 up to {@code FIELD_COUNT}. */ public int get(int field) { complete(); return fields[field]; }
/** * Returns the minimum value of the given field for the current date. */ public int getActualMinimum(int field) { int value, next; if (getMinimum(field) == (next = getGreatestMinimum(field))) { return next; } complete(); long orgTime = time; set(field, next); do { value = next; roll(field, false); next = get(field); } while (next < value); time = orgTime; areFieldsSet = false; return value; }
/** * Returns the maximum value of the given field for the current date. * For example, the maximum number of days in the current month. */ public int getActualMaximum(int field) { int value, next; if (getMaximum(field) == (next = getLeastMaximum(field))) { return next; } complete(); long orgTime = time; set(field, next); do { value = next; roll(field, true); next = get(field); } while (next > value); time = orgTime; areFieldsSet = false; return value; }
/** * Returns a map of human-readable strings to corresponding values, * for the given field, style, and locale. * Returns null if no strings are available. * * <p>For example, {@code getDisplayNames(MONTH, ALL_STYLES, Locale.US)} would * contain mappings from "Jan" and "January" to {@link #JANUARY}, and so on. * * @param field the field * @param style {@code SHORT}, {@code LONG}, or {@code ALL_STYLES} * @param locale the locale * @return the display name, or null * @throws NullPointerException if {@code locale == null} * @throws IllegalArgumentException if {@code field} or {@code style} is invalid * @since 1.6 */ public Map<String, Integer> getDisplayNames(int field, int style, Locale locale) { checkStyle(style); complete(); Map<String, Integer> result = new HashMap<String, Integer>(); if (style == SHORT || style == ALL_STYLES) { insertValuesInMap(result, getDisplayNameArray(field, SHORT, locale)); } if (style == LONG || style == ALL_STYLES) { insertValuesInMap(result, getDisplayNameArray(field, LONG, locale)); } return result.isEmpty() ? null : result; }
private void writeObject(ObjectOutputStream stream) throws IOException { complete(); ObjectOutputStream.PutField putFields = stream.putFields(); putFields.put("areFieldsSet", areFieldsSet); putFields.put("fields", this.fields); putFields.put("firstDayOfWeek", firstDayOfWeek); putFields.put("isSet", isSet); putFields.put("isTimeSet", isTimeSet); putFields.put("lenient", lenient); putFields.put("minimalDaysInFirstWeek", minimalDaysInFirstWeek); putFields.put("nextStamp", 2 /* MINIMUM_USER_STAMP */); putFields.put("serialVersionOnStream", 1); putFields.put("time", time); putFields.put("zone", zone); stream.writeFields(); }
/** * Sets the time of this {@code Calendar} to the given Unix time. See {@link Date} for more * about what this means. */ public void setTimeInMillis(long milliseconds) { if (!isTimeSet || !areFieldsSet || time != milliseconds) { time = milliseconds; isTimeSet = true; areFieldsSet = false; complete(); } }
/** * Sets the time of this {@code Calendar} to the given Unix time. See {@link Date} for more * about what this means. */ public void setTimeInMillis(long milliseconds) { if (!isTimeSet || !areFieldsSet || time != milliseconds) { time = milliseconds; isTimeSet = true; areFieldsSet = false; complete(); } }
/** * Sets the time of this {@code Calendar} to the given Unix time. See {@link Date} for more * about what this means. */ public void setTimeInMillis(long milliseconds) { if (!isTimeSet || !areFieldsSet || time != milliseconds) { time = milliseconds; isTimeSet = true; areFieldsSet = false; complete(); } }
/** * Sets the time of this {@code Calendar} to the given Unix time. See {@link Date} for more * about what this means. */ public void setTimeInMillis(long milliseconds) { if (!isTimeSet || !areFieldsSet || time != milliseconds) { time = milliseconds; isTimeSet = true; areFieldsSet = false; complete(); } }
/** * Sets the time of this {@code Calendar} to the given Unix time. See {@link Date} for more * about what this means. */ public void setTimeInMillis(long milliseconds) { if (!isTimeSet || !areFieldsSet || time != milliseconds) { time = milliseconds; isTimeSet = true; areFieldsSet = false; complete(); } }
/** * Sets the time of this {@code Calendar} to the given Unix time. See {@link Date} for more * about what this means. */ public void setTimeInMillis(long milliseconds) { if (!isTimeSet || !areFieldsSet || time != milliseconds) { time = milliseconds; isTimeSet = true; areFieldsSet = false; complete(); } }
/** * Sets the time of this {@code Calendar} to the given Unix time. See {@link Date} for more * about what this means. */ public void setTimeInMillis(long milliseconds) { if (!isTimeSet || !areFieldsSet || time != milliseconds) { time = milliseconds; isTimeSet = true; areFieldsSet = false; complete(); } }
/** * Returns the value of the given field after computing the field values by * calling {@code complete()} first. * * @throws IllegalArgumentException if the fields are not set, the time is not set, and the * time cannot be computed from the current field values. * @throws ArrayIndexOutOfBoundsException if the field is not inside the range of possible fields. * The range is starting at 0 up to {@code FIELD_COUNT}. */ public int get(int field) { complete(); return fields[field]; }
/** * Returns the value of the given field after computing the field values by * calling {@code complete()} first. * * @throws IllegalArgumentException * if the fields are not set, the time is not set, and the * time cannot be computed from the current field values. * @throws ArrayIndexOutOfBoundsException * if the field is not inside the range of possible fields. * The range is starting at 0 up to {@code FIELD_COUNT}. */ public int get(int field) { complete(); return fields[field]; }
/** * Returns the value of the given field after computing the field values by * calling {@code complete()} first. * * @throws IllegalArgumentException * if the fields are not set, the time is not set, and the * time cannot be computed from the current field values. * @throws ArrayIndexOutOfBoundsException * if the field is not inside the range of possible fields. * The range is starting at 0 up to {@code FIELD_COUNT}. */ public int get(int field) { complete(); return fields[field]; }
/** * Returns the value of the given field after computing the field values by * calling {@code complete()} first. * * @throws IllegalArgumentException * if the fields are not set, the time is not set, and the * time cannot be computed from the current field values. * @throws ArrayIndexOutOfBoundsException * if the field is not inside the range of possible fields. * The range is starting at 0 up to {@code FIELD_COUNT}. */ public int get(int field) { complete(); return fields[field]; }
/** * Returns the value of the given field after computing the field values by * calling {@code complete()} first. * * @throws IllegalArgumentException * if the fields are not set, the time is not set, and the * time cannot be computed from the current field values. * @throws ArrayIndexOutOfBoundsException * if the field is not inside the range of possible fields. * The range is starting at 0 up to {@code FIELD_COUNT}. */ public int get(int field) { complete(); return fields[field]; }
java.lang.IllegalArgumentException: DAY_OF_MONTH at java.util.GregorianCalendar.computeTime(GregorianCalendar.java:2316) at java.util.Calendar.updateTime(Calendar.java:2260) at java.util.Calendar.complete(Calendar.java:1305) at java.util.Calendar.get(Calendar.java:1088)
private void writeObject(ObjectOutputStream stream) throws IOException { complete(); ObjectOutputStream.PutField putFields = stream.putFields(); putFields.put("areFieldsSet", areFieldsSet); putFields.put("fields", this.fields); putFields.put("firstDayOfWeek", firstDayOfWeek); putFields.put("isSet", isSet); putFields.put("isTimeSet", isTimeSet); putFields.put("lenient", lenient); putFields.put("minimalDaysInFirstWeek", minimalDaysInFirstWeek); putFields.put("nextStamp", 2 /* MINIMUM_USER_STAMP */); putFields.put("serialVersionOnStream", 1); putFields.put("time", time); putFields.put("zone", zone); stream.writeFields(); }