Clover Coverage Report - Kuali Student 1.1-SNAPSHOT (Aggregated)
Coverage timestamp: Thu Mar 3 2011 04:02:59 EST
../../../../../../img/srcFileCovDistChart7.png 38% of files have more coverage
13   57   5   6.5
4   29   0.38   2
2     2.5  
1    
 
  ServerDateParser       Line # 21 13 0% 5 7 63.2% 0.6315789
 
  (3)
 
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.old;
17   
18    import java.text.SimpleDateFormat;
19    import java.util.Date;
20   
 
21    public class ServerDateParser implements DateParser {
22    SimpleDateFormat[] formats = {new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ"), new SimpleDateFormat("yyyy-MM-dd")};
23   
 
24  6 toggle public Date parseDate(String input) {
25  6 Date result = null;
26   
27  6 for (SimpleDateFormat format : formats) {
28  12 try {
29  12 result = format.parse(input);
30    } catch (Exception e) {
31    // just eat it
32    }
33  12 if (result != null) {
34  6 break;
35    }
36   
37    }
38   
39  6 if (result == null) {
40  0 throw new DateParseException("Invalid date value: " + input);
41    }
42   
43  6 return result;
44    }
45   
46    /**
47    * @see org.kuali.student.common.validator.old.DateParser#toString(java.util.Date)
48    */
 
49  0 toggle @Override
50    public String toString(Date date) {
51  0 String result = null;
52  0 SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-ddTHH:mm:ss,SSS");
53  0 result = format.format(date);
54   
55  0 return result;
56    }
57    }