// Path: core/src/main/java/com/caseystella/analytics/converters/Converter.java
// public interface Converter<T, S> extends Serializable {
//     T convert(S in, Map<String, Object> config );
// }
// 
// Path: core/src/main/java/com/caseystella/analytics/converters/MappingConverter.java
// public interface MappingConverter extends Converter<Map<String, Object>, byte[]> {
// }
// 
// Path: core/src/main/java/com/caseystella/analytics/converters/TimestampConverter.java
// public interface TimestampConverter extends Converter<Long, Object>{
// }


import com.caseystella.analytics.converters.Converter;
import com.caseystella.analytics.converters.MappingConverter;
import com.caseystella.analytics.converters.TimestampConverter;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
package com.caseystella.analytics.converters.primitive;



public class DateConverter {
    public static final String FORMAT_CONF = "format";
    public static final String NAME_CONF = "name";
    public static final String TO_TS_CONF = "to_ts";

    public static class DateTimestampConverter implements TimestampConverter {
        @Override
        public Long convert(Object in, Map<String, Object> config) {
            if(in instanceof Date) {
                return ((Date)in).getTime();
            }
            else if(in instanceof String)
            {
                String format = (String) config.get(FORMAT_CONF);
                SimpleDateFormat sdf = new SimpleDateFormat(format);
                String s = in.toString();
                try {
                    Date d = sdf.parse(s);
                    return d.getTime();
                } catch (ParseException e) {
                    throw new RuntimeException("Malformed Date: " + s);
                }
            }
            else {
                throw new RuntimeException("Unable to convert " + in + " to date");
            }
        }
    }

// Path: core/src/main/java/com/caseystella/analytics/converters/Converter.java
// public interface Converter<T, S> extends Serializable {
//     T convert(S in, Map<String, Object> config );
// }
// 
// Path: core/src/main/java/com/caseystella/analytics/converters/MappingConverter.java
// public interface MappingConverter extends Converter<Map<String, Object>, byte[]> {
// }
// 
// Path: core/src/main/java/com/caseystella/analytics/converters/TimestampConverter.java
// public interface TimestampConverter extends Converter<Long, Object>{
// }


// Path: core/src/main/java/com/caseystella/analytics/converters/primitive/DateConverter.java
import com.caseystella.analytics.converters.Converter;
import com.caseystella.analytics.converters.MappingConverter;
import com.caseystella.analytics.converters.TimestampConverter;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

package com.caseystella.analytics.converters.primitive;



public class DateConverter {
    public static final String FORMAT_CONF = "format";
    public static final String NAME_CONF = "name";
    public static final String TO_TS_CONF = "to_ts";

    public static class DateTimestampConverter implements TimestampConverter {
        @Override
        public Long convert(Object in, Map<String, Object> config) {
            if(in instanceof Date) {
                return ((Date)in).getTime();
            }
            else if(in instanceof String)
            {
                String format = (String) config.get(FORMAT_CONF);
                SimpleDateFormat sdf = new SimpleDateFormat(format);
                String s = in.toString();
                try {
                    Date d = sdf.parse(s);
                    return d.getTime();
                } catch (ParseException e) {
                    throw new RuntimeException("Malformed Date: " + s);
                }
            }
            else {
                throw new RuntimeException("Unable to convert " + in + " to date");
            }
        }
    }

    public static class DateMappingConverter implements MappingConverter{