Represent the interval for a given timestamp using the specified interval type.
Represent the interval for a given timestamp using the specified interval type.
This will truncate lower resolution date fields to their initial value, for example for months the day of month field is set to 1.
Example:
scala> Day(1431000000000L).format("yyyy-MM-dd HH:mm ZZ") res1: String = 2015-05-07 00:00 +0000 scala> Month(1431000000000L).format("yyyy-MM-dd HH:mm ZZ") res2: String = 2015-05-01 00:00 +0000 scala> Year(1431000000000L).format("yyyy-MM-dd HH:mm ZZ") res3: String = 2015-01-01 00:00 +0000
Create a date interval with a different type and truncate lower resolution date fields accordingly.
Create a date interval with a different type and truncate lower resolution date fields accordingly.
Example:
scala> Day(1431000000000L) res1: DateInterval = 2015-05-07 scala> Week(Day(1431000000000L)) res2: DateInterval = 2015-W19 scala> Month(Day(1431000000000L)) res3: DateInterval = 2015-05 scala> Quarter(1431000000000L) res4: DateInterval = 2015-Q2 scala> Year(Day(1431000000000L)) res5: DateInterval = 2015 scala> Year(Day(1431000000000L)).format("yyyy-MM-dd HH:mm ZZ") res6: String = 2015-01-01 00:00 +0000
Parse a timestamp into a date interval.
Parse a timestamp into a date interval.
Example:
scala> Day.parse("2015-05-07") res1: Option[DateInterval] = Some(2015-05-07) scala> Day.parse("2015-05-07").get.format("yyyy-MM-dd HH:mm ZZ") res2: String = 2015-05-07 00:00 +0000
Represent the interval for today using the specified interval type.
Represent the interval for today using the specified interval type.
This will truncate lower resolution date fields to their initial value, for example for months the day of month field is set to 1.
Base class for specific date intervals