TimeFormatter

The TimeFormatter object handles temporal values and provides easy access to custom formats for display or further use

Author

N7ghtm4r3 - Tecknobit

Since

1.0.6

Properties

Link copied to clipboard

AMERICAN_DATE_PATTERN the date pattern used in the american zone

Link copied to clipboard

COMPLETE_AMERICAN_DATE_PATTERN the complete date pattern used in the american zone

Link copied to clipboard

COMPLETE_EUROPEAN_DATE_PATTERN the complete date pattern used in the european zone

Link copied to clipboard

COMPLETE_ISO_8601_DATE_PATTERN the complete date pattern standardised from the ISO 8601

Link copied to clipboard

COMPLETE_TIME_PATTERN the complete time pattern with hours (24 format), minutes, seconds and milliseconds

Link copied to clipboard

defaultPattern the default pattern used by the TimeFormatter if no custom one is specified

Link copied to clipboard

EUROPEAN_DATE_PATTERN the date pattern used in the european zone

Link copied to clipboard

H12_HOURS_MINUTES_PATTERN the pattern with hours (12 format) and minutes

Link copied to clipboard

H12_HOURS_MINUTES_SECONDS_PATTERN the pattern with hours (12 format), minutes and seconds

Link copied to clipboard

H24_HOURS_MINUTES_PATTERN the pattern with hours (24 format) and minutes

Link copied to clipboard

H24_HOURS_MINUTES_SECONDS_PATTERN the pattern with hours (24 format), minutes and seconds

Link copied to clipboard

invalidTimeDefValue the default value returned when an error occurred during the formatting

Link copied to clipboard

invalidTimeStringDefValue the default value returned when an error occurred during the formatting of a String value

Link copied to clipboard

ISO_8601_DATE_PATTERN the date pattern standardised from the ISO 8601

Link copied to clipboard
private const val MILLIS_GAP_CONVERSION_RATE: Int = 1000

MILLIS_GAP_CONVERSION_RATE conversion rate from millis to other time format

Link copied to clipboard
private const val SEXAGESIMAL_CONVERSION_RATE: Int = 60

SEXAGESIMAL_CONVERSION_RATE rate for a sexagesimal system conversion

Link copied to clipboard
private const val TIME_PATTERN_REGEX: String

TIME_PATTERN_REGEX regex pattern used from the toTimestamp method to distinguish what proper method use (one from dateAndTimeParsing or dateParsing) to correctly format the pattern parameter passed as argument

Link copied to clipboard
private val timePattern: Regex

timePattern the regex validator for the TIME_PATTERN_REGEX

Functions

Link copied to clipboard
fun Long.centuriesUntil(untilDate: Long): Int

Method used to count the centuries passed from the Long value to the untilDate

Link copied to clipboard

Method used to count the centuries passed from the Long value to the current timestamp

Link copied to clipboard
private fun computeUntilGap(baseDate: Long, untilDate: Long, untilGap: DateTimeUnit.DateBased): Int

Method used to calculate a temporal gap between the baseDate and the untilDate

Link copied to clipboard

Method used to get the current timestamp value in milliseconds

Link copied to clipboard
private fun String.dateAndTimeParsing(pattern: String): Long

Method used to format a String value which contains both date and time related values

Link copied to clipboard
private fun String.dateParsing(pattern: String): Long

Method used to format a String value which contains just date related values

Link copied to clipboard
fun Long.daysUntil(untilDate: Long): Int

Method used to count the days passed from the Long value to the untilDate

Link copied to clipboard

Method used to count the days passed from the Long value to the current timestamp

Link copied to clipboard
fun formatNowAsString(pattern: String = defaultPattern): String

Method used to format the current timestamp as string

Link copied to clipboard
fun Long.hoursUntil(untilDate: Long): Int

Method used to count the hours passed from the Long value to the untilDate

Link copied to clipboard

Method used to count the hours passed from the Long value to the current timestamp

Link copied to clipboard
fun Long.millisecondsUntil(untilDate: Long): Long

Method used to count the milliseconds passed from the Long value to the untilDate

Link copied to clipboard

Method used to count the milliseconds passed from the Long value to the current timestamp

Link copied to clipboard
fun Long.minutesUntil(untilDate: Long): Int

Method used to count the minutes passed from the Long value to the untilDate

Link copied to clipboard

Method used to count the minutes passed from the Long value to the current timestamp

Link copied to clipboard
fun Long.monthsUntil(untilDate: Long): Int

Method used to count the months passed from the Long value to the untilDate

Link copied to clipboard

Method used to count the months passed from the Long value to the current timestamp

Link copied to clipboard
fun Long.nanosecondsUntil(untilDate: Long): Long

Method used to count the nanoseconds passed from the Long value to the untilDate

Link copied to clipboard

Method used to count the nanoseconds passed from the Long value to the current timestamp

Link copied to clipboard
fun Long.quartersUntil(untilDate: Long): Int

Method used to count the quarters passed from the Long value to the untilDate

Link copied to clipboard

Method used to count the quarters passed from the Long value to the current timestamp

Link copied to clipboard
fun Long.secondsUntil(untilDate: Long): Int

Method used to count the seconds passed from the Long value to the untilDate

Link copied to clipboard

Method used to count the seconds passed from the Long value to the current timestamp

Link copied to clipboard
fun Long.toDateString(invalidTimeDefValue: String? = null, pattern: String = defaultPattern): String

Method used to format a Long value into the corresponding date-string value

Link copied to clipboard
fun Long.toLocalDate(): LocalDate

Method used to transform a Long value into the corresponding LocalDate

Link copied to clipboard
fun Long.toLocalDateTime(): LocalDateTime

Method used to transform a Long value into the corresponding LocalDateTime

Link copied to clipboard
fun LocalDateTime.toMillis(): Long

Method used to transform a LocalDateTime value into the corresponding milliseconds value

Link copied to clipboard
fun LocalDateTime.toNanos(): Long

Method used to transform a LocalDateTime value into the corresponding nanoseconds value

Link copied to clipboard
fun LocalDateTime.toSeconds(): Long

Method used to transform a LocalDateTime value into the corresponding seconds value

Link copied to clipboard
fun String.toTimestamp(invalidTimeDefValue: Long? = null, pattern: String = defaultPattern): Long

Method used to format a String value into the corresponding timestamp value

Link copied to clipboard
fun Long.weeksUntil(untilDate: Long): Int

Method used to count the weeks passed from the Long value to the untilDate

Link copied to clipboard

Method used to count the weeks passed from the Long value to the current timestamp

Link copied to clipboard
fun Long.yearsUntil(untilDate: Long): Int

Method used to count the years passed from the Long value to the untilDate

Link copied to clipboard

Method used to count the years passed from the Long value to the current timestamp