Here you can find the source of parseDates(String query)
public static Date[] parseDates(String query)
//package com.java2s; //License from project: Apache License import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; import java.util.List; import java.util.regex.Pattern; public class Main { private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy/MM/dd"); private static final Pattern SPLIT_PATTERN = Pattern.compile("-"); public static Date[] parseDates(String query) { String[] segments = SPLIT_PATTERN.split(query); List<Date> dates = new ArrayList<>(); for (String s : segments) { Date date = parse(s.trim()); if (date != null) { dates.add(date);/*from w w w . j a va 2s . c o m*/ } } return dates.toArray(new Date[dates.size()]); } private static Date parse(String source) { if (source.equalsIgnoreCase("today")) { return new Date(); } if (source.equalsIgnoreCase("yesterday")) { Calendar cal = Calendar.getInstance(); cal.add(Calendar.DATE, -1); return cal.getTime(); } try { return DATE_FORMAT.parse(source); } catch (ParseException e) { return null; } } }