io.logspace.jvm.agent.api.json.DateEventPropertyJsonHandler Maven / Gradle / Ivy
The newest version!
/**
* Logspace
* Copyright (c) 2015 Indoqa Software Design und Beratung GmbH. All rights reserved.
* This program and the accompanying materials are made available under the terms of
* the Eclipse Public License Version 1.0, which accompanies this distribution and
* is available at http://www.eclipse.org/legal/epl-v10.html.
*/
package io.logspace.jvm.agent.api.json;
import java.io.IOException;
import java.util.Date;
import io.logspace.jvm.agent.shaded.jackson.core.JsonGenerator;
import io.logspace.jvm.agent.shaded.jackson.core.JsonParser;
import io.logspace.jvm.agent.api.event.DateEventProperty;
import io.logspace.jvm.agent.api.event.EventProperties;
public class DateEventPropertyJsonHandler extends AbstractEventPropertyJsonHandler {
public static final String FIELD_NAME = "date-properties";
@Override
public String getFieldName() {
return FIELD_NAME;
}
@Override
protected void readPropertyValue(EventProperties eventProperties, String propertyName, JsonParser jsonParser) throws IOException {
String propertyValue = jsonParser.getText();
eventProperties.add(new DateEventProperty(propertyName, JacksonUtils.parseDateValue(propertyValue)));
}
@Override
protected void writePropertyValue(JsonGenerator jsonGenerator, Date propertyValue) throws IOException {
jsonGenerator.writeString(JacksonUtils.formatDate(propertyValue));
}
}