1 package com.atlassian.jira.util;
2
3 import java.text.ParseException;
4 import java.util.Date;
5 import java.util.Locale;
6 import java.util.Map;
7
8 import org.apache.log4j.Logger;
9
10 import com.atlassian.jira.ManagerFactory;
11 import com.opensymphony.util.TextUtils;
12
13
14
15
16
17
18
19
20 public class ExtendedParameterUtils extends ParameterUtils {
21
22 private static final Logger log = Logger.getLogger(ExtendedParameterUtils.class);
23
24
25
26
27
28
29
30
31 public static Date getDateTimeParam(Map params, String s, Locale locale) throws DateTooEarlyException {
32 String paramValue = getStringParam(params, s);
33 return parseDatetime(paramValue, locale);
34
35 }
36
37
38
39
40
41
42 public static Date parseDatetime(String paramValue, Locale locale) {
43 Date date = null;
44 if (TextUtils.stringSet(paramValue)) {
45 try {
46 date = ManagerFactory.getOutlookDateManager().getOutlookDate(locale).parseDateTimePicker(paramValue);
47 if (date.getTime() < 0)
48 {
49 throw new DateTooEarlyException();
50 } else {
51 return date;
52 }
53 } catch (ParseException e) {
54 log.warn("Could not parse: " + paramValue + " into a DateTime. Try to parse as Date");
55 date = parseDate(paramValue, locale);
56 }
57 }
58 return date;
59 }
60
61 }