src/main/java/br/org/soujava/twitter/utils/DateUtils.java
public static long toEpochTime(String timeString, String pattern) {

        long epochTime = -1;

        try {

            TemporalAccessor temporalAccessor = DateTimeFormatter.ofPattern(pattern).withLocale(Locale.US).parse(timeString);
            LocalDateTime localDateTime = LocalDateTime.from(temporalAccessor);

            epochTime = localDateTime.toEpochSecond(ZoneOffset.UTC);

        } catch (Exception e) {
            logger.error("Unable to convert into epoch time. Time: '{}', Pattern: '{}'", timeString, pattern, e);
        }

        return epochTime;
    }
/**
     * Func to transform a string to long using a pattern
     * @param timeString
     * @param pattern
     * @return
     */
Func to transform a string to long using a pattern
@param timeString
@param pattern
@return
Func to transform a string to long using a pattern @param timeString @param pattern @return
public static long toEpochTime(String timeString, String pattern) {
        long epochTime = -1;
        try {
            TemporalAccessor temporalAccessor = DateTimeFormatter.ofPattern(pattern).withLocale(Locale.US).parse(timeString);
            LocalDateTime localDateTime = LocalDateTime.from(temporalAccessor);
            epochTime = localDateTime.toEpochSecond(ZoneOffset.UTC);
        } catch (Exception e) {
            logger.error("Unable to convert into epoch time. Time: '{}', Pattern: '{}'", timeString, pattern, e);
        }
        return epochTime;
    }
public static long toEpochTime ( String timeString , String pattern ) { long epochTime = - 1 ; try { TemporalAccessor temporalAccessor = DateTimeFormatter . ofPattern ( pattern ) . withLocale ( Locale . US ) . parse ( timeString ) ; LocalDateTime localDateTime = LocalDateTime . from ( temporalAccessor ) ; epochTime = localDateTime . toEpochSecond ( ZoneOffset . UTC ) ; } catch ( Exception e ) { logger . error ( "Unable to convert into epoch time. Time: '{}', Pattern: '{}'" , timeString , pattern , e ) ; } return epochTime ; }
Func to transform a string to long using a pattern
 @param timeString
 @param pattern
 @return
Func to transform a string to long using a pattern @param timeString @param pattern @return