Class CommonTools
java.lang.Object
de.aristaflow.adept2.model.common.tools.CommonTools
This class offers tool methods for several models.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringdateTimeToOffsetString(ZonedDateTime dateTime) Gets the designated date-time as ISO-8601 text with its offset, e. g.static StringdateTimeToZonedString(ZonedDateTime dateTime) Gets the designated date-time as ISO-8601 text with its offset and, if it has one, its region, e. g.static StringgetTypeAsString(ProcessConstants.AdeptDataType adt, String udtName) Gets a string representation of the designatedProcessConstants.AdeptDataType.static StringgetTypeAsString(ProcessConstants.AdeptDataType adt, String udtName, String any) Gets a string representation of the designatedProcessConstants.AdeptDataType.static ZonedDateTimeparseDateTime(String dateTime) Parses an ISO-8601 date-time with its offset, e. g.static TemporalAmountparseTimeAmount(String period) Parses an ISO-8601 period.static StringtimeAmountToString(TemporalAmount period) Gets the designated period as ISO-8601 text, e. g.
-
Constructor Details
-
CommonTools
public CommonTools()
-
-
Method Details
-
getTypeAsString
Gets a string representation of the designatedProcessConstants.AdeptDataType. In case of aProcessConstants.AdeptDataType.USERDEFINEDtype, the UDT name will be appended if notnull.- Parameters:
adt- The data type for which to get a string representation. This must not benull.udtName- The name of the user-defined type ornull.- Returns:
- A string representation for the designated data type.
-
getTypeAsString
public static String getTypeAsString(ProcessConstants.AdeptDataType adt, String udtName, String any) Gets a string representation of the designatedProcessConstants.AdeptDataType. In case of aProcessConstants.AdeptDataType.USERDEFINEDtype, the UDT name will be appended if notnull. If the designated data type isnullor if it isProcessConstants.AdeptDataType.USERDEFINEDand the UDT name isnull, the designatedanystring will be used. This is especially for parameter templates of which the data type/UDT name does not matter.- Parameters:
adt- The data type for which to get a string representation. This may benullin caseanyis provided.udtName- The name of the user-defined type ornull.any- The string representation for when the data type/UDT name does not matter. This must not benullif eitheradtorudtNamearenull.- Returns:
- A string representation for the designated data type including "do not care".
-
dateTimeToOffsetString
Gets the designated date-time as ISO-8601 text with its offset, e. g.2026-10-01T06:00:00+02:00, the form ofxs:dateTime. The text does not keep the region of the date-time.- Parameters:
dateTime- The date-time to convert to text. This must not benull.- Returns:
- The designated date-time as ISO-8601 text with its offset.
-
dateTimeToZonedString
Gets the designated date-time as ISO-8601 text with its offset and, if it has one, its region, e. g.2026-10-01T06:00:00+02:00[Europe/Berlin]. Unlike the offset, the region determines the offsets of later times across a change of daylight saving time.- Parameters:
dateTime- The date-time to convert to text. This must not benull.- Returns:
- The designated date-time as ISO-8601 text with its offset and its region.
-
parseDateTime
Parses an ISO-8601 date-time with its offset, e. g.2026-10-01T06:00:00+02:00, or with its offset and its region, e. g.2026-10-01T06:00:00+02:00[Europe/Berlin]. A date-time without an offset is taken as UTC.- Parameters:
dateTime- The ISO-8601 date-time to parse. This must not benull.- Returns:
- The date-time in the region of the designated text if it has one, otherwise at its offset.
- Throws:
DateTimeParseException- If the designated text is no ISO-8601 date-time, aDateTimeParseExceptionwill be thrown.
-
timeAmountToString
Gets the designated period as ISO-8601 text, e. g.PT2HorP1M.- Parameters:
period- The period to convert to text. This must not benull.- Returns:
- The designated period as ISO-8601 text.
-
parseTimeAmount
Parses an ISO-8601 period. A text with a time part is aDuration, a fixed length of time whose days count as 24 hours, e. g.PT2HorP1DT12H. Any other text is aPeriodof calendar days, weeks, months or years, e. g.P1DorP1M, so that a day may last 23 or 25 hours across a change to or from daylight saving time. This reads the text oftimeAmountToString(TemporalAmount)back as the same type.- Parameters:
period- The ISO-8601 period to parse. This must not benull.- Returns:
- The designated period as
DurationorPeriod. - Throws:
DateTimeParseException- If the designated text is no ISO-8601 period, aDateTimeParseExceptionwill be thrown.
-