org.zodiac.netty.http.headers.InstantHeader Maven / Gradle / Ivy
package org.zodiac.netty.http.headers;
import java.time.Instant;
import java.time.ZonedDateTime;
final class InstantHeader implements TimestampHeader {
private final DateTimeHeader delegate;
InstantHeader(DateTimeHeader delegate) {
this.delegate = delegate;
}
@Override
public Class type() {
return Instant.class;
}
@Override
public CharSequence name() {
return delegate.name();
}
@Override
public Instant toValue(CharSequence value) {
return delegate.toValue(value).toInstant();
}
@Override
public String toString(Instant value) {
return delegate.toString(ZonedDateTime.ofInstant(value, DateTimeHeader.GMT));
}
@Override
public CharSequence toCharSequence(Instant value) {
return delegate.toCharSequence(ZonedDateTime.ofInstant(value, DateTimeHeader.GMT));
}
@Override
public TimestampHeader toInstantHeader() {
return this;
}
}