<commit_before>package au.gov.ga.geodesy.support.mapper.orika.geodesyml;

import java.text.ParseException;
import java.util.Arrays;
import java.util.Date;
import java.util.Optional;
import java.util.TimeZone;

import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.FastDateFormat;

import ma.glasnost.orika.MappingContext;
import ma.glasnost.orika.converter.BidirectionalConverter;
import ma.glasnost.orika.metadata.Type;

import net.opengis.gml.v_3_2_1.TimePositionType;

public class DateToTimePositionConverter extends BidirectionalConverter<Date, TimePositionType> {

    private static final TimeZone UTC = TimeZone.getTimeZone("UTC");

    private static final String defaultTimePositionPattern = "yyyy-MM-dd'T'HH:mm:ss.SSSXXX";

    private static final String[] timePositionPatterns = {
        defaultTimePositionPattern,
        "yyyy-MM-dd'T'HH:mm:ss.SSSZ",
        "yyyy-MM-dd'T'HH:mm:ssX",
        "yyyy-MM-ddX",
    };

    private FastDateFormat dateFormat(String pattern) {
        return FastDateFormat.getInstance(pattern, UTC);
    }

    public TimePositionType convertTo(Date date, Type<TimePositionType> targetType, MappingContext ctx) {
        TimePositionType time = new TimePositionType();
        time.getValue().add(dateFormat(defaultTimePositionPattern).format(date));
        return time;
    }

    public Date convertFrom(TimePositionType time, Type<Date> targetType, MappingContext ctx) {<commit_msg>Add todo<commit_after>package au.gov.ga.geodesy.support.mapper.orika.geodesyml;

import java.text.ParseException;
import java.util.Arrays;
import java.util.Date;
import java.util.Optional;
import java.util.TimeZone;

import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.FastDateFormat;

import ma.glasnost.orika.MappingContext;
import ma.glasnost.orika.converter.BidirectionalConverter;
import ma.glasnost.orika.metadata.Type;

import net.opengis.gml.v_3_2_1.TimePositionType;

// TODO: swap type parameters, DTO first
public class DateToTimePositionConverter extends BidirectionalConverter<Date, TimePositionType> {

    private static final TimeZone UTC = TimeZone.getTimeZone("UTC");

    private static final String defaultTimePositionPattern = "yyyy-MM-dd'T'HH:mm:ss.SSSXXX";

    private static final String[] timePositionPatterns = {
        defaultTimePositionPattern,
        "yyyy-MM-dd'T'HH:mm:ss.SSSZ",
        "yyyy-MM-dd'T'HH:mm:ssX",
        "yyyy-MM-ddX",
    };

    private FastDateFormat dateFormat(String pattern) {
        return FastDateFormat.getInstance(pattern, UTC);
    }

    public TimePositionType convertTo(Date date, Type<TimePositionType> targetType, MappingContext ctx) {
        TimePositionType time = new TimePositionType();
        time.getValue().add(dateFormat(defaultTimePositionPattern).format(date));
        return time;
    }

    public Date convertFrom(TimePositionType time, Type<Date> targetType, MappingContext ctx) {
{'fraction_non_alphanumeric': 0.10284167794316644, 'fraction_numerical': 0.0033829499323410014, 'mean_word_length': 4.589792060491494, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3528545', 'n_tokens_mistral': 919, 'n_tokens_neox': 896, 'n_words': 169}