| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
package dr.app.beauti.tipdatepanel; |
| 27 |
|
| 28 |
import dr.app.beauti.options.DateGuesser; |
| 29 |
import dr.app.beauti.util.TextUtil; |
| 30 |
import dr.app.gui.components.RealNumberField; |
| 31 |
import jam.mac.Utils; |
| 32 |
import jam.panels.OptionsPanel; |
| 33 |
|
| 34 |
|
| 35 |
import javax.swing.*; |
| 36 |
import javax.swing.border.EmptyBorder; |
| 37 |
import java.awt.*; |
| 38 |
import java.awt.event.*; |
| 39 |
import java.util.Calendar; |
| 40 |
import java.util.GregorianCalendar; |
| 41 |
import java.util.prefs.Preferences; |
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
public class GuessDatesDialog { |
| 49 |
|
| 50 |
public static Preferences PREFS = Preferences.userNodeForPackage(GuessDatesDialog.class); |
| 51 |
public static final String DELIMIT_RADIO_KEY = "delimitRadio"; |
| 52 |
public static final String ORDER_COMBO_KEY = "orderCombo"; |
| 53 |
public static final String PREFIX_TEXT_KEY = "prefixText"; |
| 54 |
public static final String REGEX_TEXT_KEY = "regexText"; |
| 55 |
public static final String LOAD_TEXT_KEY = "loadText"; |
| 56 |
public static final String PARSE_RADIO_KEY = "parseRadio"; |
| 57 |
public static final String OFFSET_CHECK_KEY = "offsetCheck"; |
| 58 |
public static final String OFFSET_TEXT_KEY = "offsetText"; |
| 59 |
public static final String UNLESS_CHECK_KEY = "unlessCheck"; |
| 60 |
public static final String UNLESS_TEXT_KEY = "unlessText"; |
| 61 |
public static final String OFFSET2_TEXT_KEY = "offset2Text"; |
| 62 |
public static final String DATE_FORMAT_TEXT_KEY = "dateFormatText"; |
| 63 |
|
| 64 |
private JFrame frame; |
| 65 |
|
| 66 |
private final OptionsPanel optionPanel; |
| 67 |
|
| 68 |
private final JRadioButton orderRadio = new JRadioButton("Defined just by its order", true); |
| 69 |
private final JComboBox orderCombo = new JComboBox(new String[]{"first", "second", "third", |
| 70 |
"fourth", "fourth from last", |
| 71 |
"third from last", "second from last", "last"}); |
| 72 |
private final JLabel orderLabel = new JLabel("Order:"); |
| 73 |
private final JLabel prefixLabel = new JLabel("Prefix:"); |
| 74 |
|
| 75 |
private final JRadioButton prefixRadio = new JRadioButton("Defined by a prefix and its order", false); |
| 76 |
private final JTextField prefixText = new JTextField(16); |
| 77 |
|
| 78 |
private final JRadioButton regexRadio = new JRadioButton("Defined by regular expression (REGEX)", false); |
| 79 |
private final JTextField regexText = new JTextField(16); |
| 80 |
|
| 81 |
private final JRadioButton numericalRadio = new JRadioButton("Parse as a number", true); |
| 82 |
private final JRadioButton calendarRadio = new JRadioButton("Parse as a calendar date", true); |
| 83 |
private final JRadioButton calendar2Radio = new JRadioButton("Parse calendar dates with variable precision", true); |
| 84 |
|
| 85 |
private final JCheckBox offsetCheck = new JCheckBox("Add the following value to each: ", false); |
| 86 |
private final RealNumberField offsetText = new RealNumberField(); |
| 87 |
|
| 88 |
private final JCheckBox unlessCheck = new JCheckBox("...unless less than:", false); |
| 89 |
private final RealNumberField unlessText = new RealNumberField(); |
| 90 |
|
| 91 |
private final RealNumberField offset2Text = new RealNumberField(); |
| 92 |
|
| 93 |
private final JTextField dateFormatText = new JTextField(16); |
| 94 |
private String description = "Extract dates from taxon labels"; |
| 95 |
|
| 96 |
private final int defaultDelimitRadioOption; |
| 97 |
private final int defaultOrderCombo; |
| 98 |
private final String defaultPrefixText; |
| 99 |
private final String defaultRegexText; |
| 100 |
private final int defaultParseRadioOption; |
| 101 |
private final boolean defaultOffsetCheckOption; |
| 102 |
private final String defaultOffsetText; |
| 103 |
private final boolean defaultUnlessCheckOption; |
| 104 |
private final String defaultUnlessText; |
| 105 |
private final String defaultOffset2Text; |
| 106 |
private final String defaultDateFormatText; |
| 107 |
|
| 108 |
public GuessDatesDialog(final JFrame frame) { |
| 109 |
this.frame = frame; |
| 110 |
defaultDelimitRadioOption = PREFS.getInt(DELIMIT_RADIO_KEY, 0); |
| 111 |
defaultOrderCombo = PREFS.getInt(ORDER_COMBO_KEY, 0); |
| 112 |
defaultPrefixText = PREFS.get(PREFIX_TEXT_KEY, ""); |
| 113 |
defaultRegexText = PREFS.get(REGEX_TEXT_KEY, ""); |
| 114 |
defaultParseRadioOption = PREFS.getInt(PARSE_RADIO_KEY, 0); |
| 115 |
defaultOffsetCheckOption = PREFS.getBoolean(OFFSET_CHECK_KEY, false); |
| 116 |
defaultOffsetText = PREFS.get(OFFSET_TEXT_KEY, "1900"); |
| 117 |
defaultUnlessCheckOption = PREFS.getBoolean(UNLESS_CHECK_KEY, false); |
| 118 |
defaultUnlessText = PREFS.get(UNLESS_TEXT_KEY, "16"); |
| 119 |
defaultOffset2Text = PREFS.get(OFFSET2_TEXT_KEY, "2000"); |
| 120 |
defaultDateFormatText = PREFS.get(DATE_FORMAT_TEXT_KEY, "yyyy-MM-dd"); |
| 121 |
|
| 122 |
optionPanel = new OptionsPanel(12, 12); |
| 123 |
} |
| 124 |
|
| 125 |
private void setupPanel(boolean parsingFromFile) { |
| 126 |
|
| 127 |
optionPanel.removeAll(); |
| 128 |
|
| 129 |
if (parsingFromFile) { |
| 130 |
|
| 131 |
} else { |
| 132 |
optionPanel.addLabel("The date is given by a numerical field in the taxon label that is:"); |
| 133 |
|
| 134 |
optionPanel.addSpanningComponent(orderRadio); |
| 135 |
|
| 136 |
|
| 137 |
optionPanel.addSpanningComponent(prefixRadio); |
| 138 |
|
| 139 |
optionPanel.addComponents(orderLabel, orderCombo); |
| 140 |
optionPanel.addComponents(prefixLabel, prefixText); |
| 141 |
|
| 142 |
prefixLabel.setEnabled(false); |
| 143 |
prefixText.setEnabled(false); |
| 144 |
regexText.setEnabled(false); |
| 145 |
|
| 146 |
optionPanel.addComponents(regexRadio, regexText); |
| 147 |
|
| 148 |
optionPanel.addSeparator(); |
| 149 |
} |
| 150 |
|
| 151 |
optionPanel.addSpanningComponent(numericalRadio); |
| 152 |
|
| 153 |
offsetText.setValue(1900); |
| 154 |
offsetText.setColumns(16); |
| 155 |
offsetText.setEnabled(false); |
| 156 |
optionPanel.addComponents(offsetCheck, offsetText); |
| 157 |
|
| 158 |
Calendar calendar = GregorianCalendar.getInstance(); |
| 159 |
|
| 160 |
int year = calendar.get(Calendar.YEAR) - 1999; |
| 161 |
unlessText.setValue(year); |
| 162 |
unlessText.setColumns(16); |
| 163 |
unlessText.setEnabled(false); |
| 164 |
optionPanel.addComponents(unlessCheck, unlessText); |
| 165 |
|
| 166 |
offset2Text.setValue(2000); |
| 167 |
offset2Text.setColumns(16); |
| 168 |
offset2Text.setEnabled(false); |
| 169 |
final JLabel offset2Label = new JLabel("...in which case add:"); |
| 170 |
optionPanel.addComponents(offset2Label, offset2Text); |
| 171 |
|
| 172 |
optionPanel.addSpanningComponent(calendarRadio); |
| 173 |
final JLabel dateFormatLabel = new JLabel("Date format:"); |
| 174 |
final JButton helpButton = new JButton(Utils.isMacOSX() ? "" : "?"); |
| 175 |
helpButton.putClientProperty("JButton.buttonType", "help"); |
| 176 |
JPanel panel = new JPanel(); |
| 177 |
panel.add(dateFormatText); |
| 178 |
panel.add(helpButton); |
| 179 |
panel.setOpaque(false); |
| 180 |
optionPanel.addComponents(dateFormatLabel, panel); |
| 181 |
dateFormatText.setText("yyyy-MM-dd"); |
| 182 |
|
| 183 |
optionPanel.addSpanningComponent(calendar2Radio); |
| 184 |
|
| 185 |
dateFormatLabel.setEnabled(false); |
| 186 |
dateFormatText.setEnabled(false); |
| 187 |
|
| 188 |
numericalRadio.setToolTipText("Parse the date field as a decimal number"); |
| 189 |
calendarRadio.setToolTipText("Parse the date field using a standard date format specification"); |
| 190 |
calendar2Radio.setToolTipText("Parse the date field yyyy[-mm[-dd]] with possibly missing month or day"); |
| 191 |
|
| 192 |
helpButton.addActionListener(new ActionListener() { |
| 193 |
public void actionPerformed(final ActionEvent actionEvent) { |
| 194 |
JScrollPane scrollPane = TextUtil.createHTMLScrollPane( |
| 195 |
DATE_FORMAT_HELP, new Dimension(560,480)); |
| 196 |
JOptionPane.showMessageDialog(frame, scrollPane, |
| 197 |
"Date format help", |
| 198 |
JOptionPane.PLAIN_MESSAGE); |
| 199 |
} |
| 200 |
}); |
| 201 |
|
| 202 |
offsetCheck.addItemListener(new ItemListener() { |
| 203 |
public void itemStateChanged(ItemEvent e) { |
| 204 |
offsetText.setEnabled(offsetCheck.isSelected()); |
| 205 |
unlessCheck.setEnabled(offsetCheck.isSelected()); |
| 206 |
unlessText.setEnabled(offsetCheck.isSelected() && unlessCheck.isSelected()); |
| 207 |
offset2Label.setEnabled(offsetCheck.isSelected() && unlessCheck.isSelected()); |
| 208 |
offset2Text.setEnabled(offsetCheck.isSelected() && unlessCheck.isSelected()); |
| 209 |
} |
| 210 |
}); |
| 211 |
|
| 212 |
unlessCheck.addItemListener(new ItemListener() { |
| 213 |
public void itemStateChanged(ItemEvent e) { |
| 214 |
unlessText.setEnabled(unlessCheck.isSelected()); |
| 215 |
offset2Label.setEnabled(unlessCheck.isSelected()); |
| 216 |
offset2Text.setEnabled(unlessCheck.isSelected()); |
| 217 |
} |
| 218 |
}); |
| 219 |
|
| 220 |
if (!parsingFromFile) { |
| 221 |
ButtonGroup group = new ButtonGroup(); |
| 222 |
group.add(orderRadio); |
| 223 |
group.add(prefixRadio); |
| 224 |
group.add(regexRadio); |
| 225 |
orderRadio.setSelected(true); |
| 226 |
ItemListener listener = new ItemListener() { |
| 227 |
public void itemStateChanged(ItemEvent e) { |
| 228 |
orderLabel.setEnabled(!regexRadio.isSelected()); |
| 229 |
orderCombo.setEnabled(!regexRadio.isSelected()); |
| 230 |
prefixLabel.setEnabled(prefixRadio.isSelected()); |
| 231 |
prefixText.setEnabled(prefixRadio.isSelected()); |
| 232 |
regexText.setEnabled(regexRadio.isSelected()); |
| 233 |
} |
| 234 |
}; |
| 235 |
orderRadio.addItemListener(listener); |
| 236 |
prefixRadio.addItemListener(listener); |
| 237 |
regexRadio.addItemListener(listener); |
| 238 |
} |
| 239 |
|
| 240 |
ButtonGroup group = new ButtonGroup(); |
| 241 |
group.add(numericalRadio); |
| 242 |
group.add(calendarRadio); |
| 243 |
group.add(calendar2Radio); |
| 244 |
ItemListener listener = new ItemListener() { |
| 245 |
public void itemStateChanged(ItemEvent e) { |
| 246 |
boolean nrs = numericalRadio.isSelected(); |
| 247 |
boolean ocs = offsetCheck.isSelected(); |
| 248 |
boolean ucs = unlessCheck.isSelected(); |
| 249 |
boolean crs = calendarRadio.isSelected(); |
| 250 |
offsetCheck.setEnabled(nrs); |
| 251 |
offsetText.setEnabled(nrs && ocs); |
| 252 |
unlessCheck.setEnabled(nrs && ocs); |
| 253 |
unlessText.setEnabled(nrs && ocs && ucs); |
| 254 |
offset2Label.setEnabled(nrs && ocs && ucs); |
| 255 |
offset2Text.setEnabled(nrs && ocs && ucs); |
| 256 |
dateFormatLabel.setEnabled(crs); |
| 257 |
dateFormatText.setEnabled(crs); |
| 258 |
|
| 259 |
} |
| 260 |
}; |
| 261 |
numericalRadio.addItemListener(listener); |
| 262 |
calendarRadio.addItemListener(listener); |
| 263 |
calendar2Radio.addItemListener(listener); |
| 264 |
|
| 265 |
offsetCheck.setSelected(defaultOffsetCheckOption); |
| 266 |
offsetText.setText(defaultOffsetText); |
| 267 |
unlessCheck.setSelected(defaultUnlessCheckOption); |
| 268 |
unlessText.setText(defaultUnlessText); |
| 269 |
offset2Text.setText(defaultOffset2Text); |
| 270 |
|
| 271 |
dateFormatText.setText(defaultDateFormatText); |
| 272 |
|
| 273 |
orderCombo.setSelectedIndex(defaultOrderCombo); |
| 274 |
prefixText.setText(defaultPrefixText); |
| 275 |
regexText.setText(defaultRegexText); |
| 276 |
|
| 277 |
orderCombo.setSelectedIndex(defaultOrderCombo); |
| 278 |
prefixText.setText(defaultPrefixText); |
| 279 |
regexText.setText(defaultRegexText); |
| 280 |
|
| 281 |
|
| 282 |
switch (defaultDelimitRadioOption) { |
| 283 |
case 0: orderRadio.setSelected(true); break; |
| 284 |
case 1: prefixRadio.setSelected(true); break; |
| 285 |
case 2: regexRadio.setSelected(true); break; |
| 286 |
|
| 287 |
default: throw new IllegalArgumentException("unknown radio option"); |
| 288 |
} |
| 289 |
|
| 290 |
switch (defaultParseRadioOption) { |
| 291 |
case 0: numericalRadio.setSelected(true); break; |
| 292 |
case 1: calendarRadio.setSelected(true); break; |
| 293 |
case 2: calendar2Radio.setSelected(true); break; |
| 294 |
default: throw new IllegalArgumentException("unknown radio option"); |
| 295 |
} |
| 296 |
|
| 297 |
} |
| 298 |
|
| 299 |
public int showDialog() { |
| 300 |
return showDialog(false); |
| 301 |
} |
| 302 |
|
| 303 |
public int showDialog(boolean parsingFromFile) { |
| 304 |
|
| 305 |
setupPanel(parsingFromFile); |
| 306 |
|
| 307 |
JOptionPane optionPane = new JOptionPane(optionPanel, |
| 308 |
JOptionPane.QUESTION_MESSAGE, |
| 309 |
JOptionPane.OK_CANCEL_OPTION, |
| 310 |
null, |
| 311 |
null, |
| 312 |
null); |
| 313 |
optionPane.setBorder(new EmptyBorder(12, 12, 12, 12)); |
| 314 |
|
| 315 |
final JDialog dialog = optionPane.createDialog(frame, description); |
| 316 |
dialog.pack(); |
| 317 |
|
| 318 |
dialog.setVisible(true); |
| 319 |
|
| 320 |
int result = JOptionPane.CANCEL_OPTION; |
| 321 |
Integer value = (Integer) optionPane.getValue(); |
| 322 |
if (value != null && value != -1) { |
| 323 |
result = value; |
| 324 |
setPreferencesFromDialog(); |
| 325 |
} |
| 326 |
|
| 327 |
return result; |
| 328 |
} |
| 329 |
|
| 330 |
private void setPreferencesFromDialog() { |
| 331 |
PREFS.putInt(DELIMIT_RADIO_KEY, |
| 332 |
(orderRadio.isSelected() ? 0 : |
| 333 |
(prefixRadio.isSelected() ? 1 : |
| 334 |
(regexRadio.isSelected() ? 2 : -1)))); |
| 335 |
|
| 336 |
PREFS.putInt(ORDER_COMBO_KEY, orderCombo.getSelectedIndex()); |
| 337 |
PREFS.put(PREFIX_TEXT_KEY, prefixText.getText()); |
| 338 |
PREFS.put(REGEX_TEXT_KEY, regexText.getText()); |
| 339 |
|
| 340 |
PREFS.putInt(PARSE_RADIO_KEY, |
| 341 |
(numericalRadio.isSelected() ? 0 : |
| 342 |
(calendarRadio.isSelected() ? 1 : |
| 343 |
(calendar2Radio.isSelected() ? 2 : -1)))); |
| 344 |
|
| 345 |
PREFS.putBoolean(OFFSET_CHECK_KEY, offsetCheck.isSelected()); |
| 346 |
PREFS.put(OFFSET_TEXT_KEY, offsetText.getText()); |
| 347 |
PREFS.putBoolean(UNLESS_CHECK_KEY, unlessCheck.isSelected()); |
| 348 |
PREFS.put(UNLESS_TEXT_KEY, unlessText.getText()); |
| 349 |
PREFS.put(OFFSET2_TEXT_KEY, offset2Text.getText()); |
| 350 |
|
| 351 |
PREFS.put(DATE_FORMAT_TEXT_KEY, dateFormatText.getText()); |
| 352 |
} |
| 353 |
|
| 354 |
public void setupGuesser(DateGuesser guesser) { |
| 355 |
guesser.order = orderCombo.getSelectedIndex(); |
| 356 |
guesser.fromLast = false; |
| 357 |
if (guesser.order > 3) { |
| 358 |
guesser.fromLast = true; |
| 359 |
guesser.order = 8 - guesser.order - 1; |
| 360 |
} |
| 361 |
|
| 362 |
if (orderRadio.isSelected()) { |
| 363 |
guesser.guessType = DateGuesser.GuessType.ORDER; |
| 364 |
} else if (prefixRadio.isSelected()) { |
| 365 |
guesser.guessType = DateGuesser.GuessType.PREFIX; |
| 366 |
guesser.prefix = prefixText.getText(); |
| 367 |
} else if (regexRadio.isSelected()) { |
| 368 |
guesser.guessType = DateGuesser.GuessType.REGEX; |
| 369 |
guesser.regex = regexText.getText(); |
| 370 |
} else { |
| 371 |
throw new IllegalArgumentException("unknown radio button selected"); |
| 372 |
} |
| 373 |
|
| 374 |
guesser.parseCalendarDatesAndPrecision = calendar2Radio.isSelected(); |
| 375 |
guesser.parseCalendarDates = calendarRadio.isSelected(); |
| 376 |
guesser.calendarDateFormat = dateFormatText.getText(); |
| 377 |
|
| 378 |
guesser.offset = 0.0; |
| 379 |
guesser.unlessLessThan = 0.0; |
| 380 |
if (offsetCheck.isSelected()) { |
| 381 |
guesser.offset = offsetText.getValue(); |
| 382 |
if (unlessCheck.isSelected()) { |
| 383 |
guesser.unlessLessThan = unlessText.getValue(); |
| 384 |
guesser.offset2 = offset2Text.getValue(); |
| 385 |
|
| 386 |
} |
| 387 |
} |
| 388 |
|
| 389 |
} |
| 390 |
|
| 391 |
public void setDescription(String description) { |
| 392 |
this.description = description; |
| 393 |
} |
| 394 |
|
| 395 |
private static final String DATE_FORMAT_HELP = |
| 396 |
"<h4>Date and Time Patterns</h4>\n" + |
| 397 |
" <p>\n" + |
| 398 |
" Date and time formats are specified by <em>date and time pattern</em>\n" + |
| 399 |
" strings.\n" + |
| 400 |
" Within date and time pattern strings, unquoted letters from\n" + |
| 401 |
" <code>'A'</code> to <code>'Z'</code> and from <code>'a'</code> to\n" + |
| 402 |
" <code>'z'</code> are interpreted as pattern letters representing the\n" + |
| 403 |
" components of a date or time string.\n" + |
| 404 |
" Text can be quoted using single quotes (<code>'</code>) to avoid\n" + |
| 405 |
" interpretation.\n" + |
| 406 |
" <code>\"''\"</code> represents a single quote.\n" + |
| 407 |
" All other characters are not interpreted; they're simply copied into the\n" + |
| 408 |
" output string during formatting or matched against the input string\n" + |
| 409 |
" during parsing.\n" + |
| 410 |
" <p>\n" + |
| 411 |
" The following pattern letters are defined (all other characters from\n" + |
| 412 |
" <code>'A'</code> to <code>'Z'</code> and from <code>'a'</code> to\n" + |
| 413 |
" <code>'z'</code> are reserved):\n" + |
| 414 |
" <blockquote>\n" + |
| 415 |
" <table border=0 cellspacing=3 cellpadding=0 summary=\"Chart shows pattern letters, date/time component, presentation, and examples.\">\n" + |
| 416 |
" <tr bgcolor=\"#ccccff\">\n" + |
| 417 |
" <th align=left>Letter\n" + |
| 418 |
" <th align=left>Date or Time Component\n" + |
| 419 |
" <th align=left>Presentation\n" + |
| 420 |
" <th align=left>Examples\n" + |
| 421 |
" <tr>\n" + |
| 422 |
" <td><code>G</code>\n" + |
| 423 |
" <td>Era designator\n" + |
| 424 |
" <td><a href=\"#text\">Text</a>\n" + |
| 425 |
" <td><code>AD</code>\n" + |
| 426 |
" <tr bgcolor=\"#eeeeff\">\n" + |
| 427 |
" <td><code>y</code>\n" + |
| 428 |
" <td>Year\n" + |
| 429 |
" <td><a href=\"#year\">Year</a>\n" + |
| 430 |
" <td><code>1996</code>; <code>96</code>\n" + |
| 431 |
" <tr>\n" + |
| 432 |
" <td><code>M</code>\n" + |
| 433 |
" <td>Month in year\n" + |
| 434 |
" <td><a href=\"#month\">Month</a>\n" + |
| 435 |
" <td><code>July</code>; <code>Jul</code>; <code>07</code>\n" + |
| 436 |
" <tr bgcolor=\"#eeeeff\">\n" + |
| 437 |
" <td><code>w</code>\n" + |
| 438 |
" <td>Week in year\n" + |
| 439 |
" <td><a href=\"#number\">Number</a>\n" + |
| 440 |
" <td><code>27</code>\n" + |
| 441 |
" <tr>\n" + |
| 442 |
" <td><code>W</code>\n" + |
| 443 |
" <td>Week in month\n" + |
| 444 |
" <td><a href=\"#number\">Number</a>\n" + |
| 445 |
" <td><code>2</code>\n" + |
| 446 |
" <tr bgcolor=\"#eeeeff\">\n" + |
| 447 |
" <td><code>D</code>\n" + |
| 448 |
" <td>Day in year\n" + |
| 449 |
" <td><a href=\"#number\">Number</a>\n" + |
| 450 |
" <td><code>189</code>\n" + |
| 451 |
" <tr>\n" + |
| 452 |
" <td><code>d</code>\n" + |
| 453 |
" <td>Day in month\n" + |
| 454 |
" <td><a href=\"#number\">Number</a>\n" + |
| 455 |
" <td><code>10</code>\n" + |
| 456 |
" <tr bgcolor=\"#eeeeff\">\n" + |
| 457 |
" <td><code>F</code>\n" + |
| 458 |
" <td>Day of week in month\n" + |
| 459 |
" <td><a href=\"#number\">Number</a>\n" + |
| 460 |
" <td><code>2</code>\n" + |
| 461 |
" <tr>\n" + |
| 462 |
" <td><code>E</code>\n" + |
| 463 |
" <td>Day in week\n" + |
| 464 |
" <td><a href=\"#text\">Text</a>\n" + |
| 465 |
" <td><code>Tuesday</code>; <code>Tue</code>\n" + |
| 466 |
" <tr bgcolor=\"#eeeeff\">\n" + |
| 467 |
" <td><code>a</code>\n" + |
| 468 |
" <td>Am/pm marker\n" + |
| 469 |
" <td><a href=\"#text\">Text</a>\n" + |
| 470 |
" <td><code>PM</code>\n" + |
| 471 |
" <tr>\n" + |
| 472 |
" <td><code>H</code>\n" + |
| 473 |
" <td>Hour in day (0-23)\n" + |
| 474 |
" <td><a href=\"#number\">Number</a>\n" + |
| 475 |
" <td><code>0</code>\n" + |
| 476 |
" <tr bgcolor=\"#eeeeff\">\n" + |
| 477 |
" <td><code>k</code>\n" + |
| 478 |
" <td>Hour in day (1-24)\n" + |
| 479 |
" <td><a href=\"#number\">Number</a>\n" + |
| 480 |
" <td><code>24</code>\n" + |
| 481 |
" <tr>\n" + |
| 482 |
" <td><code>K</code>\n" + |
| 483 |
" <td>Hour in am/pm (0-11)\n" + |
| 484 |
" <td><a href=\"#number\">Number</a>\n" + |
| 485 |
" <td><code>0</code>\n" + |
| 486 |
" <tr bgcolor=\"#eeeeff\">\n" + |
| 487 |
" <td><code>h</code>\n" + |
| 488 |
" <td>Hour in am/pm (1-12)\n" + |
| 489 |
" <td><a href=\"#number\">Number</a>\n" + |
| 490 |
" <td><code>12</code>\n" + |
| 491 |
" <tr>\n" + |
| 492 |
" <td><code>m</code>\n" + |
| 493 |
" <td>Minute in hour\n" + |
| 494 |
" <td><a href=\"#number\">Number</a>\n" + |
| 495 |
" <td><code>30</code>\n" + |
| 496 |
" <tr bgcolor=\"#eeeeff\">\n" + |
| 497 |
" <td><code>s</code>\n" + |
| 498 |
" <td>Second in minute\n" + |
| 499 |
" <td><a href=\"#number\">Number</a>\n" + |
| 500 |
" <td><code>55</code>\n" + |
| 501 |
" <tr>\n" + |
| 502 |
" <td><code>S</code>\n" + |
| 503 |
" <td>Millisecond\n" + |
| 504 |
" <td><a href=\"#number\">Number</a>\n" + |
| 505 |
" <td><code>978</code>\n" + |
| 506 |
" <tr bgcolor=\"#eeeeff\">\n" + |
| 507 |
" <td><code>z</code>\n" + |
| 508 |
" <td>Time zone\n" + |
| 509 |
" <td><a href=\"#timezone\">General time zone</a>\n" + |
| 510 |
" <td><code>Pacific Standard Time</code>; <code>PST</code>; <code>GMT-08:00</code>\n" + |
| 511 |
" <tr>\n" + |
| 512 |
" <td><code>Z</code>\n" + |
| 513 |
" <td>Time zone\n" + |
| 514 |
" <td><a href=\"#rfc822timezone\">RFC 822 time zone</a>\n" + |
| 515 |
" <td><code>-0800</code>\n" + |
| 516 |
" </table>\n" + |
| 517 |
" </blockquote>\n" + |
| 518 |
" Pattern letters are usually repeated, as their number determines the\n" + |
| 519 |
" exact presentation:\n" + |
| 520 |
" <ul>\n" + |
| 521 |
" <li><strong><a name=\"text\">Text:</a></strong>\n" + |
| 522 |
" For formatting, if the number of pattern letters is 4 or more,\n" + |
| 523 |
" the full form is used; otherwise a short or abbreviated form\n" + |
| 524 |
" is used if available.\n" + |
| 525 |
" For parsing, both forms are accepted, independent of the number\n" + |
| 526 |
" of pattern letters.\n" + |
| 527 |
" <li><strong><a name=\"number\">Number:</a></strong>\n" + |
| 528 |
" For formatting, the number of pattern letters is the minimum\n" + |
| 529 |
" number of digits, and shorter numbers are zero-padded to this amount.\n" + |
| 530 |
" For parsing, the number of pattern letters is ignored unless\n" + |
| 531 |
" it's needed to separate two adjacent fields.\n" + |
| 532 |
" <li><strong><a name=\"year\">Year:</a></strong>\n" + |
| 533 |
" If the formatter's <A HREF=\"../../java/text/DateFormat.html#getCalendar()\"><CODE>Calendar</CODE></A> is the Gregorian\n" + |
| 534 |
" calendar, the following rules are applied.<br>\n" + |
| 535 |
" <ul>\n" + |
| 536 |
" <li>For formatting, if the number of pattern letters is 2, the year\n" + |
| 537 |
" is truncated to 2 digits; otherwise it is interpreted as a\n" + |
| 538 |
" <a href=\"#number\">number</a>.\n" + |
| 539 |
" <li>For parsing, if the number of pattern letters is more than 2,\n" + |
| 540 |
" the year is interpreted literally, regardless of the number of\n" + |
| 541 |
" digits. So using the pattern \"MM/dd/yyyy\", \"01/11/12\" parses to\n" + |
| 542 |
" Jan 11, 12 A.D.\n" + |
| 543 |
" <li>For parsing with the abbreviated year pattern (\"y\" or \"yy\"),\n" + |
| 544 |
" <code>SimpleDateFormat</code> must interpret the abbreviated year\n" + |
| 545 |
" relative to some century. It does this by adjusting dates to be\n" + |
| 546 |
" within 80 years before and 20 years after the time the <code>SimpleDateFormat</code>\n" + |
| 547 |
" instance is created. For example, using a pattern of \"MM/dd/yy\" and a\n" + |
| 548 |
" <code>SimpleDateFormat</code> instance created on Jan 1, 1997, the string\n" + |
| 549 |
" \"01/11/12\" would be interpreted as Jan 11, 2012 while the string \"05/04/64\"\n" + |
| 550 |
" would be interpreted as May 4, 1964.\n" + |
| 551 |
" During parsing, only strings consisting of exactly two digits, as defined by\n" + |
| 552 |
" <A HREF=\"../../java/lang/Character.html#isDigit(char)\"><CODE>Character.isDigit(char)</CODE></A>, will be parsed into the default century.\n" + |
| 553 |
" Any other numeric string, such as a one digit string, a three or more digit\n" + |
| 554 |
" string, or a two digit string that isn't all digits (for example, \"-1\"), is\n" + |
| 555 |
" interpreted literally. So \"01/02/3\" or \"01/02/003\" are parsed, using the\n" + |
| 556 |
" same pattern, as Jan 2, 3 AD. Likewise, \"01/02/-3\" is parsed as Jan 2, 4 BC.\n" + |
| 557 |
" </ul>\n" + |
| 558 |
" Otherwise, calendar system specific forms are applied.\n" + |
| 559 |
" For both formatting and parsing, if the number of pattern\n" + |
| 560 |
" letters is 4 or more, a calendar specific <A HREF=\"../../java/util/Calendar.html#LONG\">long form</A> is used. Otherwise, a calendar\n" + |
| 561 |
" specific <A HREF=\"../../java/util/Calendar.html#SHORT\">short or abbreviated form</A>\n" + |
| 562 |
" is used.\n" + |
| 563 |
" <li><strong><a name=\"month\">Month:</a></strong>\n" + |
| 564 |
" If the number of pattern letters is 3 or more, the month is\n" + |
| 565 |
" interpreted as <a href=\"#text\">text</a>; otherwise,\n" + |
| 566 |
" it is interpreted as a <a href=\"#number\">number</a>.\n" + |
| 567 |
" </ul>"; |
| 568 |
|
| 569 |
} |