Coverage Report - org.dozer.converters.DateFormatContainer
 
Classes in this File Line Coverage Branch Coverage Complexity
DateFormatContainer
100%
9/9
100%
4/4
1.5
 
 1  
 /**
 2  
  * Copyright 2005-2013 Dozer Project
 3  
  *
 4  
  * Licensed under the Apache 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.apache.org/licenses/LICENSE-2.0
 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.dozer.converters;
 17  
 
 18  
 import java.text.DateFormat;
 19  
 import java.text.SimpleDateFormat;
 20  
 import java.util.Locale;
 21  
 
 22  
 /**
 23  
  * Internal class used as a container to determine the date format to use for a particular field mapping. Only intended
 24  
  * for internal use.  
 25  
  * 
 26  
  * @author tierney.matt
 27  
  */
 28  
 public class DateFormatContainer {
 29  
   private String dfStr;
 30  
   private DateFormat dateFormat;
 31  
 
 32  46344
   public DateFormatContainer(String dfStr) {
 33  46344
     this.dfStr = dfStr;
 34  46344
   }
 35  
 
 36  
   public DateFormat getDateFormat() {
 37  260
     if (dateFormat == null) {
 38  205
       dateFormat = determineDateFormat();
 39  
     }
 40  260
     return dateFormat;
 41  
   }
 42  
 
 43  
   public void setDateFormat(DateFormat dateFormat) {
 44  35
     this.dateFormat = dateFormat;
 45  35
   }
 46  
 
 47  
   private DateFormat determineDateFormat() {
 48  205
     return dfStr == null ? null : new SimpleDateFormat(dfStr, Locale.getDefault());
 49  
   }
 50  
 }