1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
package org.kuali.student.contract.model.util; |
17 |
|
|
18 |
|
import java.text.DateFormat; |
19 |
|
import java.text.ParseException; |
20 |
|
import java.text.SimpleDateFormat; |
21 |
|
import java.util.Date; |
22 |
|
|
23 |
|
import org.kuali.student.contract.exception.DictionaryExecutionException; |
24 |
|
|
25 |
|
|
26 |
|
|
27 |
|
@author |
28 |
|
|
|
|
| 0% |
Uncovered Elements: 28 (28) |
Complexity: 8 |
Complexity Density: 0.47 |
|
29 |
|
public class DateUtility { |
30 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
31 |
0
|
public String asYMD(String date)... |
32 |
|
throws ParseException { |
33 |
0
|
if (date == null) { |
34 |
0
|
return null; |
35 |
|
} |
36 |
0
|
return asYMD(asDate(date)); |
37 |
|
} |
38 |
|
|
|
|
| 0% |
Uncovered Elements: 14 (14) |
Complexity: 4 |
Complexity Density: 0.4 |
|
39 |
0
|
public Date asDate(String date)... |
40 |
|
throws ParseException { |
41 |
0
|
if (date == null) { |
42 |
0
|
return null; |
43 |
|
} |
44 |
0
|
String[] formats = { |
45 |
|
"yyyy-MM-dd", |
46 |
|
"MM/dd/yyyy" |
47 |
|
}; |
48 |
0
|
ParseException pe = null; |
49 |
0
|
for (int i = 0; i < formats.length; i++) { |
50 |
0
|
DateFormat df = new SimpleDateFormat(formats[i]); |
51 |
0
|
try { |
52 |
0
|
return df.parse(date); |
53 |
|
} catch (ParseException e) { |
54 |
0
|
pe = e; |
55 |
|
} |
56 |
|
} |
57 |
0
|
throw pe; |
58 |
|
} |
59 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
60 |
0
|
public String asYMD(Date date) {... |
61 |
0
|
if (date == null) { |
62 |
0
|
return null; |
63 |
|
} |
64 |
0
|
DateFormat df = new SimpleDateFormat("yyyy-MM-dd"); |
65 |
0
|
return df.format(date); |
66 |
|
} |
67 |
|
} |