1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.student.r1.common.validator.old;
17
18 import java.text.SimpleDateFormat;
19 import java.util.Date;
20
21 @Deprecated
22 public class ServerDateParser implements DateParser {
23 private static ThreadLocal<SimpleDateFormat[]> formats = new ThreadLocal<SimpleDateFormat[]>() {
24
25 protected SimpleDateFormat[] initialValue() {
26 return new SimpleDateFormat[] {
27 new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ"),
28 new SimpleDateFormat("yyyy-MM-dd")
29 };
30 }
31
32 };
33
34 public Date parseDate(String input) {
35 Date result = null;
36
37 for (SimpleDateFormat format : formats.get()) {
38 try {
39 result = format.parse(input);
40 } catch (Exception e) {
41
42 }
43 if (result != null) {
44 break;
45 }
46
47 }
48
49 if (result == null) {
50 throw new DateParseException("Invalid date value: " + input);
51 }
52
53 return result;
54 }
55
56
57
58
59 @Override
60 public String toString(Date date) {
61 String result = null;
62 SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-ddTHH:mm:ss,SSS");
63 result = format.format(date);
64
65 return result;
66 }
67 }