com.backblaze.b2.json.B2JsonLocalDateTimeHandler Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of b2-sdk-core Show documentation
Show all versions of b2-sdk-core Show documentation
The core logic for B2 SDK for Java. Does not include any implementations of B2WebApiClient.
/*
* Copyright 2017, Backblaze Inc. All Rights Reserved.
* License https://www.backblaze.com/using_b2_code.html
*/
package com.backblaze.b2.json;
import com.backblaze.b2.util.B2DateTimeUtil;
import java.io.IOException;
import java.time.LocalDateTime;
public class B2JsonLocalDateTimeHandler implements B2JsonTypeHandler {
public Class getHandledClass() {
return LocalDateTime.class;
}
public void serialize(LocalDateTime obj, B2JsonWriter out) throws IOException, B2JsonException {
out.writeString(B2DateTimeUtil.formatFguidDateTime(obj));
}
public LocalDateTime deserialize(B2JsonReader in, int options) throws B2JsonException, IOException {
String str = in.readString();
return B2DateTimeUtil.parseDateTime(str);
}
public LocalDateTime deserializeUrlParam(String urlValue) throws B2JsonException {
return B2DateTimeUtil.parseDateTime(urlValue);
}
public LocalDateTime defaultValueForOptional() {
return null;
}
public boolean isStringInJson() {
return true;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy