java.util.Calendar.complete()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(8.9k)|赞(0)|评价(0)|浏览(272)

本文整理了Java中java.util.Calendar.complete()方法的一些代码示例,展示了Calendar.complete()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Calendar.complete()方法的具体详情如下:
包路径:java.util.Calendar
类名称:Calendar
方法名:complete

Calendar.complete介绍

[英]Computes the time from the fields if the time has not already been set. Computes the fields from the time if the fields are not already set.
[中]如果尚未设置时间,则从字段计算时间。如果尚未设置字段,则从时间开始计算字段。

代码示例

代码示例来源:origin: robovm/robovm

  1. /**
  2. * Sets the time of this {@code Calendar} to the given Unix time. See {@link Date} for more
  3. * about what this means.
  4. */
  5. public void setTimeInMillis(long milliseconds) {
  6. if (!isTimeSet || !areFieldsSet || time != milliseconds) {
  7. time = milliseconds;
  8. isTimeSet = true;
  9. areFieldsSet = false;
  10. complete();
  11. }
  12. }

代码示例来源:origin: robovm/robovm

  1. /**
  2. * Returns the value of the given field after computing the field values by
  3. * calling {@code complete()} first.
  4. *
  5. * @throws IllegalArgumentException
  6. * if the fields are not set, the time is not set, and the
  7. * time cannot be computed from the current field values.
  8. * @throws ArrayIndexOutOfBoundsException
  9. * if the field is not inside the range of possible fields.
  10. * The range is starting at 0 up to {@code FIELD_COUNT}.
  11. */
  12. public int get(int field) {
  13. complete();
  14. return fields[field];
  15. }

代码示例来源:origin: robovm/robovm

  1. /**
  2. * Returns the minimum value of the given field for the current date.
  3. */
  4. public int getActualMinimum(int field) {
  5. int value, next;
  6. if (getMinimum(field) == (next = getGreatestMinimum(field))) {
  7. return next;
  8. }
  9. complete();
  10. long orgTime = time;
  11. set(field, next);
  12. do {
  13. value = next;
  14. roll(field, false);
  15. next = get(field);
  16. } while (next < value);
  17. time = orgTime;
  18. areFieldsSet = false;
  19. return value;
  20. }

代码示例来源:origin: robovm/robovm

  1. /**
  2. * Returns the maximum value of the given field for the current date.
  3. * For example, the maximum number of days in the current month.
  4. */
  5. public int getActualMaximum(int field) {
  6. int value, next;
  7. if (getMaximum(field) == (next = getLeastMaximum(field))) {
  8. return next;
  9. }
  10. complete();
  11. long orgTime = time;
  12. set(field, next);
  13. do {
  14. value = next;
  15. roll(field, true);
  16. next = get(field);
  17. } while (next > value);
  18. time = orgTime;
  19. areFieldsSet = false;
  20. return value;
  21. }

代码示例来源:origin: robovm/robovm

  1. /**
  2. * Returns a map of human-readable strings to corresponding values,
  3. * for the given field, style, and locale.
  4. * Returns null if no strings are available.
  5. *
  6. * <p>For example, {@code getDisplayNames(MONTH, ALL_STYLES, Locale.US)} would
  7. * contain mappings from "Jan" and "January" to {@link #JANUARY}, and so on.
  8. *
  9. * @param field the field
  10. * @param style {@code SHORT}, {@code LONG}, or {@code ALL_STYLES}
  11. * @param locale the locale
  12. * @return the display name, or null
  13. * @throws NullPointerException if {@code locale == null}
  14. * @throws IllegalArgumentException if {@code field} or {@code style} is invalid
  15. * @since 1.6
  16. */
  17. public Map<String, Integer> getDisplayNames(int field, int style, Locale locale) {
  18. checkStyle(style);
  19. complete();
  20. Map<String, Integer> result = new HashMap<String, Integer>();
  21. if (style == SHORT || style == ALL_STYLES) {
  22. insertValuesInMap(result, getDisplayNameArray(field, SHORT, locale));
  23. }
  24. if (style == LONG || style == ALL_STYLES) {
  25. insertValuesInMap(result, getDisplayNameArray(field, LONG, locale));
  26. }
  27. return result.isEmpty() ? null : result;
  28. }

代码示例来源:origin: robovm/robovm

  1. private void writeObject(ObjectOutputStream stream) throws IOException {
  2. complete();
  3. ObjectOutputStream.PutField putFields = stream.putFields();
  4. putFields.put("areFieldsSet", areFieldsSet);
  5. putFields.put("fields", this.fields);
  6. putFields.put("firstDayOfWeek", firstDayOfWeek);
  7. putFields.put("isSet", isSet);
  8. putFields.put("isTimeSet", isTimeSet);
  9. putFields.put("lenient", lenient);
  10. putFields.put("minimalDaysInFirstWeek", minimalDaysInFirstWeek);
  11. putFields.put("nextStamp", 2 /* MINIMUM_USER_STAMP */);
  12. putFields.put("serialVersionOnStream", 1);
  13. putFields.put("time", time);
  14. putFields.put("zone", zone);
  15. stream.writeFields();
  16. }

代码示例来源:origin: ibinti/bugvm

  1. /**
  2. * Sets the time of this {@code Calendar} to the given Unix time. See {@link Date} for more
  3. * about what this means.
  4. */
  5. public void setTimeInMillis(long milliseconds) {
  6. if (!isTimeSet || !areFieldsSet || time != milliseconds) {
  7. time = milliseconds;
  8. isTimeSet = true;
  9. areFieldsSet = false;
  10. complete();
  11. }
  12. }

代码示例来源:origin: MobiVM/robovm

  1. /**
  2. * Sets the time of this {@code Calendar} to the given Unix time. See {@link Date} for more
  3. * about what this means.
  4. */
  5. public void setTimeInMillis(long milliseconds) {
  6. if (!isTimeSet || !areFieldsSet || time != milliseconds) {
  7. time = milliseconds;
  8. isTimeSet = true;
  9. areFieldsSet = false;
  10. complete();
  11. }
  12. }

代码示例来源:origin: com.bugvm/bugvm-rt

  1. /**
  2. * Sets the time of this {@code Calendar} to the given Unix time. See {@link Date} for more
  3. * about what this means.
  4. */
  5. public void setTimeInMillis(long milliseconds) {
  6. if (!isTimeSet || !areFieldsSet || time != milliseconds) {
  7. time = milliseconds;
  8. isTimeSet = true;
  9. areFieldsSet = false;
  10. complete();
  11. }
  12. }

代码示例来源:origin: com.jtransc/jtransc-rt

  1. /**
  2. * Sets the time of this {@code Calendar} to the given Unix time. See {@link Date} for more
  3. * about what this means.
  4. */
  5. public void setTimeInMillis(long milliseconds) {
  6. if (!isTimeSet || !areFieldsSet || time != milliseconds) {
  7. time = milliseconds;
  8. isTimeSet = true;
  9. areFieldsSet = false;
  10. complete();
  11. }
  12. }

代码示例来源:origin: com.gluonhq/robovm-rt

  1. /**
  2. * Sets the time of this {@code Calendar} to the given Unix time. See {@link Date} for more
  3. * about what this means.
  4. */
  5. public void setTimeInMillis(long milliseconds) {
  6. if (!isTimeSet || !areFieldsSet || time != milliseconds) {
  7. time = milliseconds;
  8. isTimeSet = true;
  9. areFieldsSet = false;
  10. complete();
  11. }
  12. }

代码示例来源:origin: com.mobidevelop.robovm/robovm-rt

  1. /**
  2. * Sets the time of this {@code Calendar} to the given Unix time. See {@link Date} for more
  3. * about what this means.
  4. */
  5. public void setTimeInMillis(long milliseconds) {
  6. if (!isTimeSet || !areFieldsSet || time != milliseconds) {
  7. time = milliseconds;
  8. isTimeSet = true;
  9. areFieldsSet = false;
  10. complete();
  11. }
  12. }

代码示例来源:origin: FlexoVM/flexovm

  1. /**
  2. * Sets the time of this {@code Calendar} to the given Unix time. See {@link Date} for more
  3. * about what this means.
  4. */
  5. public void setTimeInMillis(long milliseconds) {
  6. if (!isTimeSet || !areFieldsSet || time != milliseconds) {
  7. time = milliseconds;
  8. isTimeSet = true;
  9. areFieldsSet = false;
  10. complete();
  11. }
  12. }

代码示例来源:origin: com.jtransc/jtransc-rt

  1. /**
  2. * Returns the value of the given field after computing the field values by
  3. * calling {@code complete()} first.
  4. *
  5. * @throws IllegalArgumentException if the fields are not set, the time is not set, and the
  6. * time cannot be computed from the current field values.
  7. * @throws ArrayIndexOutOfBoundsException if the field is not inside the range of possible fields.
  8. * The range is starting at 0 up to {@code FIELD_COUNT}.
  9. */
  10. public int get(int field) {
  11. complete();
  12. return fields[field];
  13. }

代码示例来源:origin: MobiVM/robovm

  1. /**
  2. * Returns the value of the given field after computing the field values by
  3. * calling {@code complete()} first.
  4. *
  5. * @throws IllegalArgumentException
  6. * if the fields are not set, the time is not set, and the
  7. * time cannot be computed from the current field values.
  8. * @throws ArrayIndexOutOfBoundsException
  9. * if the field is not inside the range of possible fields.
  10. * The range is starting at 0 up to {@code FIELD_COUNT}.
  11. */
  12. public int get(int field) {
  13. complete();
  14. return fields[field];
  15. }

代码示例来源:origin: ibinti/bugvm

  1. /**
  2. * Returns the value of the given field after computing the field values by
  3. * calling {@code complete()} first.
  4. *
  5. * @throws IllegalArgumentException
  6. * if the fields are not set, the time is not set, and the
  7. * time cannot be computed from the current field values.
  8. * @throws ArrayIndexOutOfBoundsException
  9. * if the field is not inside the range of possible fields.
  10. * The range is starting at 0 up to {@code FIELD_COUNT}.
  11. */
  12. public int get(int field) {
  13. complete();
  14. return fields[field];
  15. }

代码示例来源:origin: com.bugvm/bugvm-rt

  1. /**
  2. * Returns the value of the given field after computing the field values by
  3. * calling {@code complete()} first.
  4. *
  5. * @throws IllegalArgumentException
  6. * if the fields are not set, the time is not set, and the
  7. * time cannot be computed from the current field values.
  8. * @throws ArrayIndexOutOfBoundsException
  9. * if the field is not inside the range of possible fields.
  10. * The range is starting at 0 up to {@code FIELD_COUNT}.
  11. */
  12. public int get(int field) {
  13. complete();
  14. return fields[field];
  15. }

代码示例来源:origin: com.mobidevelop.robovm/robovm-rt

  1. /**
  2. * Returns the value of the given field after computing the field values by
  3. * calling {@code complete()} first.
  4. *
  5. * @throws IllegalArgumentException
  6. * if the fields are not set, the time is not set, and the
  7. * time cannot be computed from the current field values.
  8. * @throws ArrayIndexOutOfBoundsException
  9. * if the field is not inside the range of possible fields.
  10. * The range is starting at 0 up to {@code FIELD_COUNT}.
  11. */
  12. public int get(int field) {
  13. complete();
  14. return fields[field];
  15. }

代码示例来源:origin: stackoverflow.com

  1. java.lang.IllegalArgumentException: DAY_OF_MONTH
  2. at java.util.GregorianCalendar.computeTime(GregorianCalendar.java:2316)
  3. at java.util.Calendar.updateTime(Calendar.java:2260)
  4. at java.util.Calendar.complete(Calendar.java:1305)
  5. at java.util.Calendar.get(Calendar.java:1088)

代码示例来源:origin: MobiVM/robovm

  1. private void writeObject(ObjectOutputStream stream) throws IOException {
  2. complete();
  3. ObjectOutputStream.PutField putFields = stream.putFields();
  4. putFields.put("areFieldsSet", areFieldsSet);
  5. putFields.put("fields", this.fields);
  6. putFields.put("firstDayOfWeek", firstDayOfWeek);
  7. putFields.put("isSet", isSet);
  8. putFields.put("isTimeSet", isTimeSet);
  9. putFields.put("lenient", lenient);
  10. putFields.put("minimalDaysInFirstWeek", minimalDaysInFirstWeek);
  11. putFields.put("nextStamp", 2 /* MINIMUM_USER_STAMP */);
  12. putFields.put("serialVersionOnStream", 1);
  13. putFields.put("time", time);
  14. putFields.put("zone", zone);
  15. stream.writeFields();
  16. }

相关文章