org.joda.time.LocalTime.isSupported()方法的使用及代码示例

x33g5p2x  于2022-01-23 转载在 其他  
字(12.5k)|赞(0)|评价(0)|浏览(173)

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

LocalTime.isSupported介绍

[英]Checks if the field type specified is supported by this local time and chronology. This can be used to avoid exceptions in #get(DateTimeFieldType).
[中]检查此本地时间和年表是否支持指定的字段类型。这可以用来避免#get(DateTimeFieldType)中的异常。

代码示例

代码示例来源:origin: joda-time/joda-time

  1. /**
  2. * Checks if the field type specified is supported by this
  3. * local time and chronology.
  4. * This can be used to avoid exceptions in {@link #get(DateTimeFieldType)}.
  5. *
  6. * @param type a field type, usually obtained from DateTimeFieldType
  7. * @return true if the field type is supported
  8. */
  9. public boolean isSupported(DateTimeFieldType type) {
  10. if (type == null) {
  11. return false;
  12. }
  13. if (isSupported(type.getDurationType()) == false) {
  14. return false;
  15. }
  16. DurationFieldType range = type.getRangeDurationType();
  17. return (isSupported(range) || range == DurationFieldType.days());
  18. }

代码示例来源:origin: JodaOrg/joda-time

  1. /**
  2. * Checks if the field type specified is supported by this
  3. * local time and chronology.
  4. * This can be used to avoid exceptions in {@link #get(DateTimeFieldType)}.
  5. *
  6. * @param type a field type, usually obtained from DateTimeFieldType
  7. * @return true if the field type is supported
  8. */
  9. public boolean isSupported(DateTimeFieldType type) {
  10. if (type == null) {
  11. return false;
  12. }
  13. if (isSupported(type.getDurationType()) == false) {
  14. return false;
  15. }
  16. DurationFieldType range = type.getRangeDurationType();
  17. return (isSupported(range) || range == DurationFieldType.days());
  18. }

代码示例来源:origin: joda-time/joda-time

  1. /**
  2. * Gets the property object for the specified type, which contains
  3. * many useful methods.
  4. *
  5. * @param fieldType the field type to get the chronology for
  6. * @return the property object
  7. * @throws IllegalArgumentException if the field is null or unsupported
  8. */
  9. public Property property(DateTimeFieldType fieldType) {
  10. if (fieldType == null) {
  11. throw new IllegalArgumentException("The DateTimeFieldType must not be null");
  12. }
  13. if (isSupported(fieldType) == false) {
  14. throw new IllegalArgumentException("Field '" + fieldType + "' is not supported");
  15. }
  16. return new Property(this, fieldType.getField(getChronology()));
  17. }

代码示例来源:origin: JodaOrg/joda-time

  1. /**
  2. * Gets the property object for the specified type, which contains
  3. * many useful methods.
  4. *
  5. * @param fieldType the field type to get the chronology for
  6. * @return the property object
  7. * @throws IllegalArgumentException if the field is null or unsupported
  8. */
  9. public Property property(DateTimeFieldType fieldType) {
  10. if (fieldType == null) {
  11. throw new IllegalArgumentException("The DateTimeFieldType must not be null");
  12. }
  13. if (isSupported(fieldType) == false) {
  14. throw new IllegalArgumentException("Field '" + fieldType + "' is not supported");
  15. }
  16. return new Property(this, fieldType.getField(getChronology()));
  17. }

代码示例来源:origin: joda-time/joda-time

  1. /**
  2. * Get the value of one of the fields of time.
  3. * <p>
  4. * This method gets the value of the specified field.
  5. * For example:
  6. * <pre>
  7. * DateTime dt = new DateTime();
  8. * int hourOfDay = dt.get(DateTimeFieldType.hourOfDay());
  9. * </pre>
  10. *
  11. * @param fieldType a field type, usually obtained from DateTimeFieldType, not null
  12. * @return the value of that field
  13. * @throws IllegalArgumentException if the field type is null
  14. */
  15. public int get(DateTimeFieldType fieldType) {
  16. if (fieldType == null) {
  17. throw new IllegalArgumentException("The DateTimeFieldType must not be null");
  18. }
  19. if (isSupported(fieldType) == false) {
  20. throw new IllegalArgumentException("Field '" + fieldType + "' is not supported");
  21. }
  22. return fieldType.getField(getChronology()).get(getLocalMillis());
  23. }

代码示例来源:origin: JodaOrg/joda-time

  1. /**
  2. * Get the value of one of the fields of time.
  3. * <p>
  4. * This method gets the value of the specified field.
  5. * For example:
  6. * <pre>
  7. * DateTime dt = new DateTime();
  8. * int hourOfDay = dt.get(DateTimeFieldType.hourOfDay());
  9. * </pre>
  10. *
  11. * @param fieldType a field type, usually obtained from DateTimeFieldType, not null
  12. * @return the value of that field
  13. * @throws IllegalArgumentException if the field type is null
  14. */
  15. public int get(DateTimeFieldType fieldType) {
  16. if (fieldType == null) {
  17. throw new IllegalArgumentException("The DateTimeFieldType must not be null");
  18. }
  19. if (isSupported(fieldType) == false) {
  20. throw new IllegalArgumentException("Field '" + fieldType + "' is not supported");
  21. }
  22. return fieldType.getField(getChronology()).get(getLocalMillis());
  23. }

代码示例来源:origin: joda-time/joda-time

  1. /**
  2. * Returns a copy of this time with the specified field set
  3. * to a new value.
  4. * <p>
  5. * For example, if the field type is <code>hourOfDay</code> then the hour of day
  6. * field would be changed in the returned instance.
  7. * If the field type is null, then <code>this</code> is returned.
  8. * <p>
  9. * These lines are equivalent:
  10. * <pre>
  11. * LocalTime updated = dt.withHourOfDay(6);
  12. * LocalTime updated = dt.withField(DateTimeFieldType.hourOfDay(), 6);
  13. * </pre>
  14. *
  15. * @param fieldType the field type to set, not null
  16. * @param value the value to set
  17. * @return a copy of this time with the field set
  18. * @throws IllegalArgumentException if the value is null or invalid
  19. */
  20. public LocalTime withField(DateTimeFieldType fieldType, int value) {
  21. if (fieldType == null) {
  22. throw new IllegalArgumentException("Field must not be null");
  23. }
  24. if (isSupported(fieldType) == false) {
  25. throw new IllegalArgumentException("Field '" + fieldType + "' is not supported");
  26. }
  27. long instant = fieldType.getField(getChronology()).set(getLocalMillis(), value);
  28. return withLocalMillis(instant);
  29. }

代码示例来源:origin: joda-time/joda-time

  1. throw new IllegalArgumentException("Field must not be null");
  2. if (isSupported(fieldType) == false) {
  3. throw new IllegalArgumentException("Field '" + fieldType + "' is not supported");

代码示例来源:origin: JodaOrg/joda-time

  1. /**
  2. * Returns a copy of this time with the specified field set
  3. * to a new value.
  4. * <p>
  5. * For example, if the field type is <code>hourOfDay</code> then the hour of day
  6. * field would be changed in the returned instance.
  7. * If the field type is null, then <code>this</code> is returned.
  8. * <p>
  9. * These lines are equivalent:
  10. * <pre>
  11. * LocalTime updated = dt.withHourOfDay(6);
  12. * LocalTime updated = dt.withField(DateTimeFieldType.hourOfDay(), 6);
  13. * </pre>
  14. *
  15. * @param fieldType the field type to set, not null
  16. * @param value the value to set
  17. * @return a copy of this time with the field set
  18. * @throws IllegalArgumentException if the value is null or invalid
  19. */
  20. public LocalTime withField(DateTimeFieldType fieldType, int value) {
  21. if (fieldType == null) {
  22. throw new IllegalArgumentException("Field must not be null");
  23. }
  24. if (isSupported(fieldType) == false) {
  25. throw new IllegalArgumentException("Field '" + fieldType + "' is not supported");
  26. }
  27. long instant = fieldType.getField(getChronology()).set(getLocalMillis(), value);
  28. return withLocalMillis(instant);
  29. }

代码示例来源:origin: JodaOrg/joda-time

  1. throw new IllegalArgumentException("Field must not be null");
  2. if (isSupported(fieldType) == false) {
  3. throw new IllegalArgumentException("Field '" + fieldType + "' is not supported");

代码示例来源:origin: camunda/camunda-bpm-platform

  1. /**
  2. * Checks if the field type specified is supported by this
  3. * local time and chronology.
  4. * This can be used to avoid exceptions in {@link #get(DateTimeFieldType)}.
  5. *
  6. * @param type a field type, usually obtained from DateTimeFieldType
  7. * @return true if the field type is supported
  8. */
  9. public boolean isSupported(DateTimeFieldType type) {
  10. if (type == null) {
  11. return false;
  12. }
  13. if (isSupported(type.getDurationType()) == false) {
  14. return false;
  15. }
  16. DurationFieldType range = type.getRangeDurationType();
  17. return (isSupported(range) || range == DurationFieldType.days());
  18. }

代码示例来源:origin: camunda/camunda-bpm-platform

  1. /**
  2. * Gets the property object for the specified type, which contains
  3. * many useful methods.
  4. *
  5. * @param fieldType the field type to get the chronology for
  6. * @return the property object
  7. * @throws IllegalArgumentException if the field is null or unsupported
  8. */
  9. public Property property(DateTimeFieldType fieldType) {
  10. if (fieldType == null) {
  11. throw new IllegalArgumentException("The DateTimeFieldType must not be null");
  12. }
  13. if (isSupported(fieldType) == false) {
  14. throw new IllegalArgumentException("Field '" + fieldType + "' is not supported");
  15. }
  16. return new Property(this, fieldType.getField(getChronology()));
  17. }

代码示例来源:origin: camunda/camunda-bpm-platform

  1. /**
  2. * Get the value of one of the fields of time.
  3. * <p>
  4. * This method gets the value of the specified field.
  5. * For example:
  6. * <pre>
  7. * DateTime dt = new DateTime();
  8. * int hourOfDay = dt.get(DateTimeFieldType.hourOfDay());
  9. * </pre>
  10. *
  11. * @param fieldType a field type, usually obtained from DateTimeFieldType, not null
  12. * @return the value of that field
  13. * @throws IllegalArgumentException if the field type is null
  14. */
  15. public int get(DateTimeFieldType fieldType) {
  16. if (fieldType == null) {
  17. throw new IllegalArgumentException("The DateTimeFieldType must not be null");
  18. }
  19. if (isSupported(fieldType) == false) {
  20. throw new IllegalArgumentException("Field '" + fieldType + "' is not supported");
  21. }
  22. return fieldType.getField(getChronology()).get(getLocalMillis());
  23. }

代码示例来源:origin: camunda/camunda-bpm-platform

  1. /**
  2. * Returns a copy of this time with the specified field set
  3. * to a new value.
  4. * <p>
  5. * For example, if the field type is <code>hourOfDay</code> then the hour of day
  6. * field would be changed in the returned instance.
  7. * If the field type is null, then <code>this</code> is returned.
  8. * <p>
  9. * These lines are equivalent:
  10. * <pre>
  11. * LocalTime updated = dt.withHourOfDay(6);
  12. * LocalTime updated = dt.withField(DateTimeFieldType.hourOfDay(), 6);
  13. * </pre>
  14. *
  15. * @param fieldType the field type to set, not null
  16. * @param value the value to set
  17. * @return a copy of this time with the field set
  18. * @throws IllegalArgumentException if the value is null or invalid
  19. */
  20. public LocalTime withField(DateTimeFieldType fieldType, int value) {
  21. if (fieldType == null) {
  22. throw new IllegalArgumentException("Field must not be null");
  23. }
  24. if (isSupported(fieldType) == false) {
  25. throw new IllegalArgumentException("Field '" + fieldType + "' is not supported");
  26. }
  27. long instant = fieldType.getField(getChronology()).set(getLocalMillis(), value);
  28. return withLocalMillis(instant);
  29. }

代码示例来源:origin: camunda/camunda-bpm-platform

  1. throw new IllegalArgumentException("Field must not be null");
  2. if (isSupported(fieldType) == false) {
  3. throw new IllegalArgumentException("Field '" + fieldType + "' is not supported");

代码示例来源:origin: Nextdoor/bender

  1. /**
  2. * Checks if the field type specified is supported by this
  3. * local time and chronology.
  4. * This can be used to avoid exceptions in {@link #get(DateTimeFieldType)}.
  5. *
  6. * @param type a field type, usually obtained from DateTimeFieldType
  7. * @return true if the field type is supported
  8. */
  9. public boolean isSupported(DateTimeFieldType type) {
  10. if (type == null) {
  11. return false;
  12. }
  13. if (isSupported(type.getDurationType()) == false) {
  14. return false;
  15. }
  16. DurationFieldType range = type.getRangeDurationType();
  17. return (isSupported(range) || range == DurationFieldType.days());
  18. }

代码示例来源:origin: org.joda/com.springsource.org.joda.time

  1. /**
  2. * Checks if the field type specified is supported by this
  3. * local time and chronology.
  4. * This can be used to avoid exceptions in {@link #get(DateTimeFieldType)}.
  5. *
  6. * @param type a field type, usually obtained from DateTimeFieldType
  7. * @return true if the field type is supported
  8. */
  9. public boolean isSupported(DateTimeFieldType type) {
  10. if (type == null) {
  11. return false;
  12. }
  13. if (isSupported(type.getDurationType()) == false) {
  14. return false;
  15. }
  16. DurationFieldType range = type.getRangeDurationType();
  17. return (isSupported(range) || range == DurationFieldType.days());
  18. }

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

  1. /**
  2. * Checks if the field type specified is supported by this
  3. * local time and chronology.
  4. * This can be used to avoid exceptions in {@link #get(DateTimeFieldType)}.
  5. *
  6. * @param type a field type, usually obtained from DateTimeFieldType
  7. * @return true if the field type is supported
  8. */
  9. public boolean isSupported(DateTimeFieldType type) {
  10. if (type == null) {
  11. return false;
  12. }
  13. if (isSupported(type.getDurationType()) == false) {
  14. return false;
  15. }
  16. DurationFieldType range = type.getRangeDurationType();
  17. return (isSupported(range) || range == DurationFieldType.days());
  18. }

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.joda-time

  1. /**
  2. * Gets the property object for the specified type, which contains
  3. * many useful methods.
  4. *
  5. * @param fieldType the field type to get the chronology for
  6. * @return the property object
  7. * @throws IllegalArgumentException if the field is null or unsupported
  8. */
  9. public Property property(DateTimeFieldType fieldType) {
  10. if (fieldType == null) {
  11. throw new IllegalArgumentException("The DateTimeFieldType must not be null");
  12. }
  13. if (isSupported(fieldType) == false) {
  14. throw new IllegalArgumentException("Field '" + fieldType + "' is not supported");
  15. }
  16. return new Property(this, fieldType.getField(getChronology()));
  17. }

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

  1. /**
  2. * Gets the property object for the specified type, which contains
  3. * many useful methods.
  4. *
  5. * @param fieldType the field type to get the chronology for
  6. * @return the property object
  7. * @throws IllegalArgumentException if the field is null or unsupported
  8. */
  9. public Property property(DateTimeFieldType fieldType) {
  10. if (fieldType == null) {
  11. throw new IllegalArgumentException("The DateTimeFieldType must not be null");
  12. }
  13. if (isSupported(fieldType) == false) {
  14. throw new IllegalArgumentException("Field '" + fieldType + "' is not supported");
  15. }
  16. return new Property(this, fieldType.getField(getChronology()));
  17. }

相关文章