Java Regex Date Vaidate parseDate(final String date, final DateTimeFormatter parser)

Here you can find the source of parseDate(final String date, final DateTimeFormatter parser)

Description

parse Date

License

Open Source License

Declaration

public static DateTime parseDate(final String date, final DateTimeFormatter parser) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import org.joda.time.DateTime;

import org.joda.time.format.DateTimeFormatter;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {
    private static final Pattern REPEATED_SPACES = Pattern.compile(" {2,}");

    public static DateTime parseDate(final String date, final DateTimeFormatter parser) {
        final String trimmed = date.replace('\n', ' ').trim();
        if (trimmed.isEmpty()) {
            return null;
        }//www.j ava  2 s  .com

        final Matcher matcher = REPEATED_SPACES.matcher(trimmed);
        return parser.parseDateTime(matcher.replaceAll(" "));
    }
}

Related

  1. dateOfAny(final String value)
  2. datePatternPattern(String appenderPrefix)
  3. dateTimeMatcher(String dt)
  4. dateTimePattern()
  5. dateToString(Date date)
  6. parseDate(String date)
  7. parseDate(String dateStr)
  8. parseDate(String entry)
  9. parseDate(String text)