![JAR search and dependency download from the Maven repository](/logo.png)
org.mnode.ical4j.json.JCalDecoder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ical4j-json Show documentation
Show all versions of ical4j-json Show documentation
Custom marshalling between iCal4j objects and JSON formats
The newest version!
package org.mnode.ical4j.json;
import net.fortuna.ical4j.model.ZoneOffsetAdapter;
import org.apache.commons.codec.StringDecoder;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
import java.util.function.Function;
public class JCalDecoder implements StringDecoder {
public static final JCalDecoder DATE = new JCalDecoder(s ->
DateTimeFormatter.BASIC_ISO_DATE.format(DateTimeFormatter.ISO_LOCAL_DATE.parse(s)));
public static final JCalDecoder DATE_TIME = new JCalDecoder(s ->
DateTimeFormatter.ofPattern("yyyyMMdd'T'HHmmss").format(DateTimeFormatter.ISO_LOCAL_DATE_TIME.parse(s)));
public static final JCalDecoder TIME = new JCalDecoder(s ->
DateTimeFormatter.ofPattern("HHmmss").format(DateTimeFormatter.ISO_LOCAL_TIME.parse(s)));
public static final JCalDecoder UTCOFFSET = new JCalDecoder(s ->
new ZoneOffsetAdapter(ZoneOffset.of(s)).toString());
private final Function function;
public JCalDecoder(Function function) {
this.function = function;
}
@Override
public String decode(String source) {
return function.apply(source);
}
@Override
public Object decode(Object source) {
return decode(source.toString());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy