Here you can find the source of parseDate(final String date, final DateTimeFormatter parser)
public static DateTime parseDate(final String date, final DateTimeFormatter parser)
//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(" ")); } }