View Javadoc
1   /**
2    * Copyright 2005-2015 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.rice.krad.uif.util;
17  
18  import org.kuali.rice.core.api.datetime.DateTimeService;
19  
20  import java.sql.Time;
21  import java.sql.Timestamp;
22  import java.text.ParseException;
23  import java.text.SimpleDateFormat;
24  import java.util.Calendar;
25  import java.util.Date;
26  
27  /**
28   * Mock {@link DateTimeService} implementation for supporting UIF unit tests.
29   *
30   * @author Kuali Rice Team (rice.collab@kuali.org)
31   */
32  public class MockDateTimeService implements DateTimeService {
33      
34      @Override
35      public String toDateString(Date date) {
36          return date == null ? null : new SimpleDateFormat("MM/dd/yy").format(date);
37      }
38  
39      @Override
40      public String toTimeString(Time time) {
41          return null;
42      }
43  
44      @Override
45      public String toDateTimeString(Date date) {
46          return null;
47      }
48  
49      @Override
50      public String toString(Date date, String pattern) {
51          return null;
52      }
53  
54      @Override
55      public Date getCurrentDate() {
56          return null;
57      }
58  
59      @Override
60      public Timestamp getCurrentTimestamp() {
61          return null;
62      }
63  
64      @Override
65      public java.sql.Date getCurrentSqlDate() {
66          return null;
67      }
68  
69      @Override
70      public java.sql.Date getCurrentSqlDateMidnight() {
71          return null;
72      }
73  
74      @Override
75      public Calendar getCurrentCalendar() {
76          return null;
77      }
78  
79      @Override
80      public Calendar getCalendar(Date date) {
81          return null;
82      }
83  
84      @Override
85      public Date convertToDate(String dateString) throws ParseException {
86          return null;
87      }
88  
89      @Override
90      public Date convertToDateTime(String dateTimeString) throws ParseException {
91          return null;
92      }
93  
94      @Override
95      public Timestamp convertToSqlTimestamp(String timeString) throws ParseException {
96          return null;
97      }
98  
99      /**
100      * Converts a date using the format string MM/dd/yy.
101      *
102      * {@inheritDoc}
103      */
104     @Override
105     public java.sql.Date convertToSqlDate(String dateString) throws ParseException {
106         return new java.sql.Date(new SimpleDateFormat("MM/dd/yy").parse(dateString).getTime());
107     }
108 
109     @Override
110     public java.sql.Date convertToSqlDateUpperBound(String dateString) throws ParseException {
111         return null;
112     }
113 
114     @Override
115     public Time convertToSqlTime(String timeString) throws ParseException {
116         return null;
117     }
118 
119     @Override
120     public java.sql.Date convertToSqlDate(Timestamp timestamp) throws ParseException {
121         return null;
122     }
123 
124     @Override
125     public int dateDiff(Date date1, Date date2, boolean inclusive) {
126         return 0;
127     }
128 
129     @Override
130     public String toDateStringForFilename(Date date) {
131         return null;
132     }
133 
134     @Override
135     public String toDateTimeStringForFilename(Date date) {
136         return null;
137     }
138 }