<commit_before>package com.capella.jsr.validators.validators;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.Instant;
import java.time.LocalDate;
import java.time.ZoneId;

/**
 * Date validator utility class
 * @author <NAME>
 */
public final class DateValidator {

    /**
     * Is given date valid
     *
     * @param dateToValidate
     * @param dateFormat
     * @return
     * @throws ParseException
     */
    public static boolean isDateValid(final String dateToValidate, String dateFormat) throws ParseException {

        if (dateToValidate == null || dateToValidate.trim().length() == 0) {
            return false;
        }

        SimpleDateFormat sdf = new SimpleDateFormat(dateFormat);
        sdf.setLenient(false);

        try {
            sdf.parse(dateToValidate);
        } catch (ParseException e) {
            throw e;
        }

        return true;
    }

    /**
     * convert to localdate
     * @param dateToValidate
     * @param dateFormat
     * @return
     * @throws ParseException
     */
    public static LocalDate toDate(final String dateToValidate, String dateFormat) throws ParseException {

        if (dateToValidate == null || dateToValidate.trim().length() == 0) {
            return null;
        }

        SimpleDateFormat sdf = new SimpleDateFormat(dateFormat);
        sdf.setLenient(false);<commit_msg>Added email validator<commit_after>package com.capella.jsr.validators.validators;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.Instant;
import java.time.LocalDate;
import java.time.ZoneId;

/**
 * Date validator utility class
 * @author <NAME>
 */
public final class DateValidator {

    /**
     * Is given date valid
     *
     * @param dateToValidate
     * @param dateFormat
     * @return
     * @throws ParseException
     */
    public static boolean isDateValid(final String dateToValidate, String dateFormat) throws ParseException {

        if (dateToValidate == null || dateToValidate.trim().length() == 0) {
            return false;
        }

        SimpleDateFormat sdf = new SimpleDateFormat(dateFormat);
        sdf.setLenient(false);

        try {
            sdf.parse(dateToValidate);
        } catch (ParseException e) {
            throw e;
        }

        return true;
    }

    /**
     * convert to localdate
     *
     * @param dateToValidate
     * @param dateFormat
     * @return
     * @throws ParseException
     */
    public static LocalDate toDate(final String dateToValidate, String dateFormat) throws ParseException {

        if (dateToValidate == null || dateToValidate.trim().length() == 0) {
            return null;
        }

        SimpleDateFormat sdf = new SimpleDateFormat(dateFormat);
        sdf.setLenient(false);
{'fraction_non_alphanumeric': 0.09576361694553222, 'fraction_numerical': 0.001423994304022784, 'mean_word_length': 2.4478527607361964, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '6615970', 'n_tokens_mistral': 787, 'n_tokens_neox': 784, 'n_words': 193}