| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| UifDateViewTimestampEditor |
|
| 3.0;3 |
| 1 | /* | |
| 2 | * Copyright 2011 The Kuali Foundation Licensed under the Educational Community | |
| 3 | * License, Version 1.0 (the "License"); you may not use this file except in | |
| 4 | * compliance with the License. You may obtain a copy of the License at | |
| 5 | * http://www.opensource.org/licenses/ecl1.php Unless required by applicable law | |
| 6 | * or agreed to in writing, software distributed under the License is | |
| 7 | * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
| 8 | * KIND, either express or implied. See the License for the specific language | |
| 9 | * governing permissions and limitations under the License. | |
| 10 | */ | |
| 11 | package org.kuali.rice.kns.web.spring; | |
| 12 | ||
| 13 | import java.sql.Date; | |
| 14 | import java.sql.Timestamp; | |
| 15 | ||
| 16 | /** | |
| 17 | * This PropertyEditor converts between date display strings and | |
| 18 | * <code>java.sql.Timestamp</code> objects using the | |
| 19 | * <code>org.kuali.rice.core.api.datetime.DateTimeService</code> | |
| 20 | * | |
| 21 | * @author Kuali Rice Team (rice.collab@kuali.org) | |
| 22 | */ | |
| 23 | 0 | public class UifDateViewTimestampEditor extends UifDateEditor { |
| 24 | ||
| 25 | /** | |
| 26 | * This overridden method uses the | |
| 27 | * <code>org.kuali.rice.core.api.datetime.DateTimeService</code> to convert | |
| 28 | * the time stamp object to the display string. | |
| 29 | * | |
| 30 | * @see org.kuali.rice.kns.web.spring.UifDateEditor#getAsText() | |
| 31 | */ | |
| 32 | @Override | |
| 33 | public String getAsText() { | |
| 34 | 0 | if (this.getValue() == null) { |
| 35 | 0 | return null; |
| 36 | } | |
| 37 | 0 | if ("".equals(this.getValue())) { |
| 38 | 0 | return null; |
| 39 | } | |
| 40 | ||
| 41 | 0 | return getDateTimeService().toDateTimeString((Timestamp) this.getValue()); |
| 42 | } | |
| 43 | ||
| 44 | /** | |
| 45 | * This overridden method converts the display string to a | |
| 46 | * <code>java.sql.Timestamp</code> object using the | |
| 47 | * <code>org.kuali.rice.core.api.datetime.DateTimeService</code>. | |
| 48 | * | |
| 49 | * @see org.kuali.rice.kns.web.spring.UifDateEditor#setAsText(java.lang.String) | |
| 50 | */ | |
| 51 | @Override | |
| 52 | public void setAsText(String text) throws IllegalArgumentException { | |
| 53 | 0 | this.setValue(new Timestamp(((Date) super.convertToObject(text)).getTime())); |
| 54 | 0 | } |
| 55 | ||
| 56 | } |