Class OpenDateException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
cloud.opencode.base.core.exception.OpenException
cloud.opencode.base.date.exception.OpenDateException
- All Implemented Interfaces:
Serializable
Date Exception Class for OpenCode Date Module
OpenCode日期模块异常类
This exception is thrown when date/time operations fail, including:
当日期时间操作失败时抛出此异常,包括:
Features | 主要功能:
- Parse failures - 解析失败
- Format failures - 格式化失败
- Invalid date/time values - 无效的日期时间值
- Timezone conversion errors - 时区转换错误
- Range validation failures - 范围验证失败
Usage Examples | 使用示例:
// Throwing parse exception
throw OpenDateException.parseError("2024-13-45", "Invalid date format");
// Throwing format exception
throw OpenDateException.formatError("Failed to format date");
// Throwing with cause
throw new OpenDateException("Operation failed", cause);
Security | 安全性:
- Thread-safe: Yes - 线程安全: 是
- Immutable: Yes - 不可变: 是
- Since:
- JDK 25, opencode-base-date V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionOpenDateException(String message) Constructs an exception with a message 使用消息构造异常OpenDateException(String message, String inputValue, String expectedFormat) Constructs an exception with all details 使用所有详细信息构造异常OpenDateException(String message, String inputValue, String expectedFormat, Throwable cause) Constructs an exception with all details and cause 使用所有详细信息和原因构造异常OpenDateException(String message, Throwable cause) Constructs an exception with a message and cause 使用消息和原因构造异常 -
Method Summary
Modifier and TypeMethodDescriptionstatic OpenDateExceptionCreates a cron expression error 创建Cron表达式错误异常static OpenDateExceptionCreates a cron expression error with cause 创建带原因的Cron表达式错误异常static OpenDateExceptionformatError(String message) Creates a format error exception 创建格式化错误异常static OpenDateExceptionformatError(String message, Throwable cause) Creates a format error exception with cause 创建带原因的格式化错误异常Gets the expected format 获取期望的格式Gets the input value that caused the exception 获取导致异常的输入值booleanChecks if expected format is available 检查期望格式是否可用booleanChecks if input value is available 检查输入值是否可用static OpenDateExceptioninvalidValue(String field, Object value, String range) Creates an invalid value exception 创建无效值异常static OpenDateExceptionparseError(String input) Creates a parse error exception for smart parsing 创建智能解析的解析错误异常static OpenDateExceptionparseError(String input, String pattern) Creates a parse error exception 创建解析错误异常static OpenDateExceptionparseError(String input, String pattern, Throwable cause) Creates a parse error exception with cause 创建带原因的解析错误异常static OpenDateExceptionrangeError(String message) Creates a range error exception 创建范围错误异常static OpenDateExceptiontimezoneError(String zoneId) Creates a timezone error exception 创建时区错误异常Methods inherited from class OpenException
getComponent, getErrorCode, getMessage, getRawMessageMethods inherited from class Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Constructor Details
-
OpenDateException
Constructs an exception with a message 使用消息构造异常- Parameters:
message- the detail message | 详细消息
-
OpenDateException
-
OpenDateException
-
OpenDateException
Constructs an exception with all details and cause 使用所有详细信息和原因构造异常- Parameters:
message- the detail message | 详细消息inputValue- the input value that caused the error | 导致错误的输入值expectedFormat- the expected format | 期望的格式cause- the cause | 原因
-
-
Method Details
-
parseError
Creates a parse error exception 创建解析错误异常- Parameters:
input- the input that failed to parse | 解析失败的输入pattern- the expected pattern | 期望的模式- Returns:
- the exception instance | 异常实例
-
parseError
Creates a parse error exception with cause 创建带原因的解析错误异常- Parameters:
input- the input that failed to parse | 解析失败的输入pattern- the expected pattern | 期望的模式cause- the cause | 原因- Returns:
- the exception instance | 异常实例
-
parseError
Creates a parse error exception for smart parsing 创建智能解析的解析错误异常- Parameters:
input- the input that failed to parse | 解析失败的输入- Returns:
- the exception instance | 异常实例
-
formatError
Creates a format error exception 创建格式化错误异常- Parameters:
message- the error message | 错误消息- Returns:
- the exception instance | 异常实例
-
formatError
Creates a format error exception with cause 创建带原因的格式化错误异常- Parameters:
message- the error message | 错误消息cause- the cause | 原因- Returns:
- the exception instance | 异常实例
-
invalidValue
Creates an invalid value exception 创建无效值异常- Parameters:
field- the field name | 字段名value- the invalid value | 无效值range- the valid range description | 有效范围描述- Returns:
- the exception instance | 异常实例
-
timezoneError
Creates a timezone error exception 创建时区错误异常- Parameters:
zoneId- the invalid zone ID | 无效的时区ID- Returns:
- the exception instance | 异常实例
-
rangeError
Creates a range error exception 创建范围错误异常- Parameters:
message- the error message | 错误消息- Returns:
- the exception instance | 异常实例
-
cronError
Creates a cron expression error 创建Cron表达式错误异常- Parameters:
expression- the invalid cron expression | 无效的Cron表达式reason- the reason | 原因- Returns:
- the exception instance | 异常实例
-
cronError
Creates a cron expression error with cause 创建带原因的Cron表达式错误异常- Parameters:
expression- the invalid cron expression | 无效的Cron表达式reason- the reason | 原因cause- the cause | 原因- Returns:
- the exception instance | 异常实例
-
getInputValue
Gets the input value that caused the exception 获取导致异常的输入值- Returns:
- the input value, or null if not available | 输入值,如果不可用则为null
-
getExpectedFormat
Gets the expected format 获取期望的格式- Returns:
- the expected format, or null if not available | 期望的格式,如果不可用则为null
-
hasInputValue
public boolean hasInputValue()Checks if input value is available 检查输入值是否可用- Returns:
- true if input value is available | 如果输入值可用则返回true
-
hasExpectedFormat
public boolean hasExpectedFormat()Checks if expected format is available 检查期望格式是否可用- Returns:
- true if expected format is available | 如果期望格式可用则返回true
-