Coverage Report - org.seasar.cubby.action.impl.FormatPatternImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
FormatPatternImpl
100%
26/26
N/A
0
 
 1  
 /*
 2  
  * Copyright 2004-2008 the Seasar Foundation and the Others.
 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,
 13  
  * either express or implied. See the License for the specific language
 14  
  * governing permissions and limitations under the License.
 15  
  */
 16  
 package org.seasar.cubby.action.impl;
 17  
 
 18  
 import java.text.DateFormat;
 19  
 import java.text.SimpleDateFormat;
 20  
 
 21  
 import org.seasar.cubby.action.FormatPattern;
 22  
 
 23  
 /**
 24  
  * 日付や時刻のフォーマットパターンを保持するクラスの実装です。
 25  
  * @author baba
 26  
  */
 27  48
 public class FormatPatternImpl implements FormatPattern {
 28  
 
 29  
         /**
 30  
          * 日付フォーマットパターン
 31  
          */
 32  48
         private String datePattern = "yyyy-MM-dd";
 33  
 
 34  
         /**
 35  
          * 時刻フォーマットパターン
 36  
          */
 37  48
         private String timePattern = "HH:mm:ss";
 38  
 
 39  
         /**
 40  
          * 日付時刻フォーマットパターン
 41  
          */
 42  48
         private String timestampPattern = "yyyy-MM-dd HH:mm:ss";
 43  
 
 44  
         /**
 45  
          * 日付フォーマットパターンを取得します。
 46  
          */
 47  
         public String getDatePattern() {
 48  14
                 return datePattern;
 49  
         }
 50  
 
 51  
         /**
 52  
          * 日付フォーマットパターンをセットします。
 53  
          * @param datePattern 日付フォーマットパターン
 54  
          */
 55  
         public void setDatePattern(String datePattern) {
 56  18
                 this.datePattern = datePattern;
 57  18
         }
 58  
 
 59  
         /**
 60  
          * 時刻フォーマットパターンを取得します。
 61  
          */
 62  
         public String getTimePattern() {
 63  12
                 return timePattern;
 64  
         }
 65  
 
 66  
         /**
 67  
          * 時刻フォーマットパターンをセットします。
 68  
          * @param timePattern 時刻フォーマットパターン
 69  
          */
 70  
         public void setTimePattern(String timePattern) {
 71  18
                 this.timePattern = timePattern;
 72  18
         }
 73  
 
 74  
         /**
 75  
          * 日付時刻フォーマットパターンを取得します。
 76  
          */
 77  
         public String getTimestampPattern() {
 78  11
                 return timestampPattern;
 79  
         }
 80  
 
 81  
         /**
 82  
          * 日付時刻フォーマットパターンをセットします。
 83  
          * @param timestampPattern 日付時刻フォーマットパターン
 84  
          */
 85  
         public void setTimestampPattern(String timestampPattern) {
 86  18
                 this.timestampPattern = timestampPattern;
 87  18
         }
 88  
 
 89  
         /**
 90  
          * 日付フォーマットを取得します。
 91  
          */
 92  
         public DateFormat getDateFormat() {
 93  2
                 return new SimpleDateFormat(this.datePattern);
 94  
         }
 95  
 
 96  
         /**
 97  
          * 時刻フォーマットを取得します。
 98  
          */
 99  
         public DateFormat getTimeFormat() {
 100  2
                 return new SimpleDateFormat(this.timePattern);
 101  
         }
 102  
 
 103  
         /**
 104  
          * 日付時刻フォーマットを取得します。
 105  
          */
 106  
         public DateFormat getTimestampFormat() {
 107  1
                 return new SimpleDateFormat(this.timestampPattern);
 108  
         }
 109  
 
 110  
         @Override
 111  
         public String toString() {
 112  41
                 StringBuilder builder = new StringBuilder();
 113  41
                 builder.append(super.toString());
 114  41
                 builder.append("[datePattern=");
 115  41
                 builder.append(datePattern);
 116  41
                 builder.append(",timePattern=");
 117  41
                 builder.append(timePattern);
 118  41
                 builder.append(",timestampPattern=");
 119  41
                 builder.append(timestampPattern);
 120  41
                 builder.append("]");
 121  41
                 return builder.toString();
 122  
         }
 123  
 
 124  
 }