Clover Coverage Report - Kuali Student 1.2-M6-SNAPSHOT (Aggregated)
Coverage timestamp: Mon Sep 12 2011 05:03:53 EDT
../../../../../img/srcFileCovDistChart7.png 33% of files have more coverage
13   63   5   6.5
4   35   0.38   2
2     2.5  
1    
 
  ServerDateParser       Line # 21 13 0% 5 7 63.2% 0.6315789
 
  (4)
 
1    /**
2    * Copyright 2010 The Kuali Foundation Licensed under the
3    * Educational Community License, Version 2.0 (the "License"); you may
4    * not use this file except in compliance with the License. You may
5    * obtain a copy of the License at
6    *
7    * http://www.osedu.org/licenses/ECL-2.0
8    *
9    * Unless required by applicable law or agreed to in writing,
10    * software distributed under the License is distributed on an "AS IS"
11    * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
12    * or implied. See the License for the specific language governing
13    * permissions and limitations under the License.
14    */
15   
16    package org.kuali.student.common.validator;
17   
18    import java.text.SimpleDateFormat;
19    import java.util.Date;
20   
 
21    public class ServerDateParser implements DateParser {
22    SimpleDateFormat[] formats = {
23    new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ"),
24    new SimpleDateFormat("yyyy-MM-dd"),
25    new SimpleDateFormat("yyyy-MMM-dd"),
26    new SimpleDateFormat("dd-MM-yyyy"),
27    new SimpleDateFormat("dd-MMM-yyyy")
28    };
29   
 
30  11 toggle public Date parseDate(String input) {
31  11 Date result = null;
32   
33  11 for (SimpleDateFormat format : formats) {
34  22 try {
35  22 result = format.parse(input);
36    } catch (Exception e) {
37    // just eat it
38    }
39  22 if (result != null) {
40  11 break;
41    }
42   
43    }
44   
45  11 if (result == null) {
46  0 throw new DateParseException("Invalid date value: " + input);
47    }
48   
49  11 return result;
50    }
51   
52    /**
53    * @see org.kuali.student.common.validator.old.DateParser#toString(java.util.Date)
54    */
 
55  0 toggle @Override
56    public String toString(Date date) {
57  0 String result = null;
58  0 SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-ddTHH:mm:ss,SSS");
59  0 result = format.format(date);
60   
61  0 return result;
62    }
63    }