List of usage examples for com.google.gwt.i18n.client DateTimeFormat getLongTimeFormat
@Deprecated public static DateTimeFormat getLongTimeFormat()
From source file:com.google.gwt.examples.DateTimeFormatExample.java
public void onModuleLoad() { Date today = new Date(); // prints Tue Dec 18 12:01:26 GMT-500 2007 in the default locale. GWT.log(today.toString());/*ww w. j av a 2 s.c o m*/ // prints 12/18/07 in the default locale GWT.log(DateTimeFormat.getShortDateFormat().format(today)); // prints December 18, 2007 in the default locale GWT.log(DateTimeFormat.getLongDateFormat().format(today)); // prints 12:01 PM in the default locale GWT.log(DateTimeFormat.getShortTimeFormat().format(today)); // prints 12:01:26 PM GMT-05:00 in the default locale GWT.log(DateTimeFormat.getLongTimeFormat().format(today)); // prints Dec 18, 2007 12:01:26 PM in the default locale GWT.log(DateTimeFormat.getMediumDateTimeFormat().format(today)); // A custom date format DateTimeFormat fmt = DateTimeFormat.getFormat("EEEE, MMMM dd, yyyy"); // prints Monday, December 17, 2007 in the default locale GWT.log(fmt.format(today)); }
From source file:com.google.gwt.sample.i18n.client.DateTimeFormatExampleController.java
License:Apache License
@Override protected String doGetPattern(String patternKey) { // Date + Time if ("fullDateTime".equals(patternKey)) { return DateTimeFormat.getFullDateTimeFormat().getPattern(); }//from w w w. j av a2 s.c o m if ("longDateTime".equals(patternKey)) { return DateTimeFormat.getLongDateTimeFormat().getPattern(); } if ("mediumDateTime".equals(patternKey)) { return DateTimeFormat.getMediumDateTimeFormat().getPattern(); } if ("shortDateTime".equals(patternKey)) { return DateTimeFormat.getShortDateTimeFormat().getPattern(); } // Date only if ("fullDate".equals(patternKey)) { return DateTimeFormat.getFullDateFormat().getPattern(); } if ("longDate".equals(patternKey)) { return DateTimeFormat.getLongDateFormat().getPattern(); } if ("mediumDate".equals(patternKey)) { return DateTimeFormat.getMediumDateFormat().getPattern(); } if ("shortDate".equals(patternKey)) { return DateTimeFormat.getShortDateFormat().getPattern(); } // Time only if ("fullTime".equals(patternKey)) { return DateTimeFormat.getFullTimeFormat().getPattern(); } if ("longTime".equals(patternKey)) { return DateTimeFormat.getLongTimeFormat().getPattern(); } if ("mediumTime".equals(patternKey)) { return DateTimeFormat.getMediumTimeFormat().getPattern(); } if ("shortTime".equals(patternKey)) { return DateTimeFormat.getShortTimeFormat().getPattern(); } throw new IllegalArgumentException("Unknown pattern key '" + patternKey + "'"); }
From source file:java.text.DateFormat.java
License:Apache License
public final static DateFormat getTimeInstance(int style) { switch (style) { case FULL:/*from w ww.j a v a 2 s .c om*/ return new SimpleDateFormat(DateTimeFormat.getFullTimeFormat()); case LONG: return new SimpleDateFormat(DateTimeFormat.getLongTimeFormat()); case SHORT: return new SimpleDateFormat(DateTimeFormat.getShortTimeFormat()); default: return getTimeInstance(); } }
From source file:net.s17fabu.vip.gwt.showcase.client.content.i18n.CwDateTimeFormat.java
License:Apache License
/** * Update the selected pattern based on the pattern in the list. *//*from w ww. j a v a 2 s . c o m*/ private void updatePattern() { switch (patternList.getSelectedIndex()) { // Date + Time case 0: activeFormat = DateTimeFormat.getFullDateTimeFormat(); patternBox.setText(activeFormat.getPattern()); patternBox.setEnabled(false); break; case 1: activeFormat = DateTimeFormat.getLongDateTimeFormat(); patternBox.setText(activeFormat.getPattern()); patternBox.setEnabled(false); break; case 2: activeFormat = DateTimeFormat.getMediumDateTimeFormat(); patternBox.setText(activeFormat.getPattern()); patternBox.setEnabled(false); break; case 3: activeFormat = DateTimeFormat.getShortDateTimeFormat(); patternBox.setText(activeFormat.getPattern()); patternBox.setEnabled(false); break; // Date only case 4: activeFormat = DateTimeFormat.getFullDateFormat(); patternBox.setText(activeFormat.getPattern()); patternBox.setEnabled(false); break; case 5: activeFormat = DateTimeFormat.getLongDateFormat(); patternBox.setText(activeFormat.getPattern()); patternBox.setEnabled(false); break; case 6: activeFormat = DateTimeFormat.getMediumDateFormat(); patternBox.setText(activeFormat.getPattern()); patternBox.setEnabled(false); break; case 7: activeFormat = DateTimeFormat.getShortDateFormat(); patternBox.setText(activeFormat.getPattern()); patternBox.setEnabled(false); break; // Time only case 8: activeFormat = DateTimeFormat.getFullTimeFormat(); patternBox.setText(activeFormat.getPattern()); patternBox.setEnabled(false); break; case 9: activeFormat = DateTimeFormat.getLongTimeFormat(); patternBox.setText(activeFormat.getPattern()); patternBox.setEnabled(false); break; case 10: activeFormat = DateTimeFormat.getMediumTimeFormat(); patternBox.setText(activeFormat.getPattern()); patternBox.setEnabled(false); break; case 11: activeFormat = DateTimeFormat.getShortTimeFormat(); patternBox.setText(activeFormat.getPattern()); patternBox.setEnabled(false); break; // Custom case 12: patternBox.setEnabled(true); String pattern = patternBox.getText(); try { activeFormat = DateTimeFormat.getFormat(pattern); } catch (IllegalArgumentException e) { showErrorMessage(constants.cwDateTimeFormatInvalidPattern()); return; } break; } // Update the formatted value updateFormattedValue(); }