functionalj.lens.lenses.java.time.ZonedDateTimeLens Maven / Gradle / Ivy
package functionalj.lens.lenses.java.time;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.time.ZonedDateTime;
import functionalj.lens.core.LensSpec;
import functionalj.lens.lenses.ObjectLensImpl;
public class ZonedDateTimeLens
extends ObjectLensImpl
implements ZonedDateTimeAccess {
public static final ZonedDateTimeLens theZonedDateTime
= new ZonedDateTimeLens(LensSpec.of(ZonedDateTime.class));
public final LocalDateTimeLens dateTime
= createSubLens(
ZonedDateTime::toLocalDateTime,
(ZonedDateTime zdt, LocalDateTime dt) -> ZonedDateTime.of(dt, zdt.getZone()),
LocalDateTimeLens::new);
// NOTE: Not sure if this 'withXXX' is right.
public final ZoneOffsetLens offset
= createSubLens(
ZonedDateTime::getOffset,
(ZonedDateTime zdt, ZoneOffset zo) -> ZonedDateTime.ofLocal(zdt.toLocalDateTime(), zdt.getZone(), zo),
ZoneOffsetLens::new);
public final ZoneIdLens zone
= createSubLens(
ZonedDateTime::getZone,
(ZonedDateTime zdt, ZoneId z) ->ZonedDateTime.of(zdt.toLocalDateTime(), z),
ZoneIdLens::new);
public static ZonedDateTimeLens of(LensSpec spec) {
return new ZonedDateTimeLens(spec);
}
public ZonedDateTimeLens(LensSpec spec) {
super(spec);
}
}