1 16 package org.joda.time.format; 17 18 33 public class ISOPeriodFormat { 34 35 36 private static PeriodFormatter cStandard; 37 38 private static PeriodFormatter cAlternate; 39 40 private static PeriodFormatter cAlternateExtended; 41 42 private static PeriodFormatter cAlternateWithWeeks; 43 44 private static PeriodFormatter cAlternateExtendedWihWeeks; 45 46 51 protected ISOPeriodFormat() { 52 super(); 53 } 54 55 64 public static PeriodFormatter standard() { 65 if (cStandard == null) { 66 cStandard = new PeriodFormatterBuilder() 67 .appendLiteral("P") 68 .appendYears() 69 .appendSuffix("Y") 70 .appendMonths() 71 .appendSuffix("M") 72 .appendWeeks() 73 .appendSuffix("W") 74 .appendDays() 75 .appendSuffix("D") 76 .appendSeparatorIfFieldsAfter("T") 77 .appendHours() 78 .appendSuffix("H") 79 .appendMinutes() 80 .appendSuffix("M") 81 .appendSecondsWithOptionalMillis() 82 .appendSuffix("S") 83 .toFormatter(); 84 } 85 return cStandard; 86 } 87 88 96 public static PeriodFormatter alternate() { 97 if (cAlternate == null) { 98 cAlternate = new PeriodFormatterBuilder() 99 .appendLiteral("P") 100 .printZeroAlways() 101 .minimumPrintedDigits(4) 102 .appendYears() 103 .minimumPrintedDigits(2) 104 .appendMonths() 105 .appendDays() 106 .appendSeparatorIfFieldsAfter("T") 107 .appendHours() 108 .appendMinutes() 109 .appendSecondsWithOptionalMillis() 110 .toFormatter(); 111 } 112 return cAlternate; 113 } 114 115 123 public static PeriodFormatter alternateExtended() { 124 if (cAlternateExtended == null) { 125 cAlternateExtended = new PeriodFormatterBuilder() 126 .appendLiteral("P") 127 .printZeroAlways() 128 .minimumPrintedDigits(4) 129 .appendYears() 130 .appendSeparator("-") 131 .minimumPrintedDigits(2) 132 .appendMonths() 133 .appendSeparator("-") 134 .appendDays() 135 .appendSeparatorIfFieldsAfter("T") 136 .appendHours() 137 .appendSeparator(":") 138 .appendMinutes() 139 .appendSeparator(":") 140 .appendSecondsWithOptionalMillis() 141 .toFormatter(); 142 } 143 return cAlternateExtended; 144 } 145 146 154 public static PeriodFormatter alternateWithWeeks() { 155 if (cAlternateWithWeeks == null) { 156 cAlternateWithWeeks = new PeriodFormatterBuilder() 157 .appendLiteral("P") 158 .printZeroAlways() 159 .minimumPrintedDigits(4) 160 .appendYears() 161 .minimumPrintedDigits(2) 162 .appendPrefix("W") 163 .appendWeeks() 164 .appendDays() 165 .appendSeparatorIfFieldsAfter("T") 166 .appendHours() 167 .appendMinutes() 168 .appendSecondsWithOptionalMillis() 169 .toFormatter(); 170 } 171 return cAlternateWithWeeks; 172 } 173 174 182 public static PeriodFormatter alternateExtendedWithWeeks() { 183 if (cAlternateExtendedWihWeeks == null) { 184 cAlternateExtendedWihWeeks = new PeriodFormatterBuilder() 185 .appendLiteral("P") 186 .printZeroAlways() 187 .minimumPrintedDigits(4) 188 .appendYears() 189 .appendSeparator("-") 190 .minimumPrintedDigits(2) 191 .appendPrefix("W") 192 .appendWeeks() 193 .appendSeparator("-") 194 .appendDays() 195 .appendSeparatorIfFieldsAfter("T") 196 .appendHours() 197 .appendSeparator(":") 198 .appendMinutes() 199 .appendSeparator(":") 200 .appendSecondsWithOptionalMillis() 201 .toFormatter(); 202 } 203 return cAlternateExtendedWihWeeks; 204 } 205 206 } 207 | Popular Tags |