package ctbrec.io;

import java.io.IOException;
import java.time.LocalTime;

import com.squareup.moshi.JsonAdapter;
import com.squareup.moshi.JsonReader;
import com.squareup.moshi.JsonWriter;

public class LocalTimeJsonAdapter extends JsonAdapter<LocalTime> {
    @Override
    public LocalTime fromJson(JsonReader reader) throws IOException {
        String timeString = reader.nextString();
        return LocalTime.parse(timeString);
    }

    @Override
    public void toJson(JsonWriter writer, LocalTime time) throws IOException {
        writer.value(time.toString());
    }
}
