Class DateTimeCaster
java.lang.Object
ortus.boxlang.runtime.dynamic.casters.DateTimeCaster
- All Implemented Interfaces:
IBoxCaster
I cast to DateTime objects
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic CastAttempt
<DateTime> Tests to see if the value can be cast.static DateTime
Used to cast anything, throwing exception if we failstatic DateTime
Used to cast anythingstatic DateTime
Used to cast anything to a DateTime object.static DateTime
Used to cast anything to a DateTime object.static boolean
isKnownDateClass
(Object object) This is not meant as a cast or instance of check really-- just a conveneince method of known date classes to differentiate a variable that could possibly be cast to a date (like) a string from a variable which is ALREADY an instance of a specific date class.
-
Constructor Details
-
DateTimeCaster
public DateTimeCaster()
-
-
Method Details
-
attempt
Tests to see if the value can be cast. Returns aCastAttempt<T>
which will contain the result if casting was was successfull, or can be interogated to proceed otherwise.- Parameters:
object
- The value to cast- Returns:
- The value
-
cast
Used to cast anything, throwing exception if we fail- Parameters:
object
- The value to cast- Returns:
- The value
-
cast
Used to cast anything- Parameters:
object
- The value to castfail
- True to throw exception when failing.- Returns:
- The value, or null when cannot be cast
-
cast
Used to cast anything to a DateTime object. We start off by testing the object against commonly known Java date objects, and then try to parse the object as a string. If we fail, we return null.- Parameters:
object
- The value to castfail
- True to throw exception when failing.timezone
- The ZoneId to ensure a timezone is applied- Returns:
- The value, or null when cannot be cast
-
cast
Used to cast anything to a DateTime object. We start off by testing the object against commonly known Java date objects, and then try to parse the object as a string. If we fail, we return null.- Parameters:
object
- The value to castfail
- True to throw exception when failing.timezone
- The ZoneId to ensure a timezone is appliedclone
- If true, will return a clone of the object if it was originally a DateTime.- Returns:
- The value, or null when cannot be cast
-
isKnownDateClass
This is not meant as a cast or instance of check really-- just a conveneince method of known date classes to differentiate a variable that could possibly be cast to a date (like) a string from a variable which is ALREADY an instance of a specific date class. If this method returns true for an object, that means it SHOULD successfully cast to a DateTime- Parameters:
object
- The object to check- Returns:
- True if the object is a known date class
-