1 23 package info.monitorenter.util; 24 25 import java.text.SimpleDateFormat ; 26 27 37 public final class SimpleDateFormatAnalyzer { 38 39 48 public static boolean displaysDay(final SimpleDateFormat format) { 49 boolean ret = false; 50 String fmt = format.toPattern(); 51 ret = fmt.indexOf('d') != -1 || fmt.indexOf('D') != -1 || fmt.indexOf('F') != -1 53 || fmt.indexOf('E') != -1; 54 return ret; 55 } 56 57 66 public static boolean displaysHour(final SimpleDateFormat format) { 67 boolean ret = false; 68 String fmt = format.toPattern(); 69 ret = fmt.indexOf('H') != -1 || fmt.indexOf('h') != -1 || fmt.indexOf('K') != -1 70 || fmt.indexOf('k') != -1; 71 return ret; 72 } 73 74 83 public static boolean displaysMillisecond(final SimpleDateFormat format) { 84 boolean ret = false; 85 String fmt = format.toPattern(); 86 ret = fmt.indexOf('S') != -1; 87 return ret; 88 } 89 90 99 public static boolean displaysMinute(final SimpleDateFormat format) { 100 boolean ret = false; 101 String fmt = format.toPattern(); 102 ret = fmt.indexOf('m') != -1; 103 return ret; 104 } 105 106 115 public static boolean displaysMonth(final SimpleDateFormat format) { 116 boolean ret = false; 117 String fmt = format.toPattern(); 118 ret = fmt.indexOf('M') != -1; 119 return ret; 120 } 121 122 131 public static boolean displaysSecond(final SimpleDateFormat format) { 132 boolean ret = false; 133 String fmt = format.toPattern(); 134 ret = fmt.indexOf('s') != -1; 135 return ret; 136 } 137 138 147 public static boolean displaysWeek(final SimpleDateFormat format) { 148 boolean ret = false; 149 String fmt = format.toPattern(); 150 ret = fmt.indexOf('W') != -1 || fmt.indexOf('w') != -1; 151 return ret; 152 } 153 154 163 public static boolean displaysYear(final SimpleDateFormat format) { 164 boolean ret = false; 165 String fmt = format.toPattern(); 166 ret = fmt.indexOf('y') != -1; 167 return ret; 168 } 169 170 174 private SimpleDateFormatAnalyzer() { 175 super(); 176 } 177 } 178 | Popular Tags |