Package org.apache.juneau.http.part
Class HttpDatePart
java.lang.Object
org.apache.juneau.http.part.HttpPartBean
org.apache.juneau.http.part.HttpDatePart
- All Implemented Interfaces:
HttpPart
An
HttpPart whose value is an ISO-8601 date-time.
Mirrors the semantics of BasicDatePart from juneau-rest-common-classic without
the Apache HttpCore dependency. Values are parsed/formatted via
DateTimeFormatter.ISO_DATE_TIME.
- Since:
- 10.0.0
-
Constructor Summary
ConstructorsConstructorDescriptionHttpDatePart(String name, String value) Constructor accepting an ISO-8601 wire-format string value.HttpDatePart(String name, ZonedDateTime value) Constructor accepting aZonedDateTimevalue.HttpDatePart(String name, Supplier<ZonedDateTime> supplier) Constructor accepting a lazyZonedDateTimesupplier. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value as anOptional<ZonedDateTime>.static HttpDatePartof(String name, ZonedDateTime value) Creates anHttpDatePartwith the given name and date value.static HttpDatePartofLazy(String name, Supplier<ZonedDateTime> supplier) Creates anHttpDatePartwith a lazy date supplier.static HttpDatePartCreates anHttpDatePartby parsing the given ISO-8601 wire value.orElse(ZonedDateTime other) Returns the value if present, otherwise returnsother.Returns the value as aZonedDateTime, ornullif not set.
-
Constructor Details
-
HttpDatePart
Constructor accepting an ISO-8601 wire-format string value.- Parameters:
name- The part name. Must not benull .value- The wire value. May benull or empty.
-
HttpDatePart
Constructor accepting aZonedDateTimevalue.- Parameters:
name- The part name. Must not benull .value- The date value. May benull .
-
HttpDatePart
Constructor accepting a lazyZonedDateTimesupplier.- Parameters:
name- The part name. Must not benull .supplier- Supplier for the date value. Must not benull .
-
-
Method Details
-
of
Creates anHttpDatePartwith the given name and date value.- Parameters:
name- The part name. Must not benull .value- The date value. May benull .- Returns:
- A new instance. Never
null .
-
ofString
Creates anHttpDatePartby parsing the given ISO-8601 wire value.- Parameters:
name- The part name. Must not benull .value- The wire value. May benull or empty.- Returns:
- A new instance. Never
null .
-
ofLazy
Creates anHttpDatePartwith a lazy date supplier.- Parameters:
name- The part name. Must not benull .supplier- Supplier for the date value. Must not benull .- Returns:
- A new instance. Never
null .
-
asZonedDateTime
Returns the value as anOptional<ZonedDateTime>.- Returns:
- The date value, wrapped in an
Optional. Nevernull .
-
orElse
Returns the value if present, otherwise returnsother.- Parameters:
other- The default value.- Returns:
- The value or
other.
-
toZonedDateTime
Returns the value as aZonedDateTime, ornullif not set.- Returns:
- The date value, possibly
null.
-