Java Code Examples for java.text.DateFormat#SHORT
The following examples show how to use
java.text.DateFormat#SHORT .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TCKLocalizedPrinterParser.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
@DataProvider(name="time") Object[][] data_time() { return new Object[][] { {LocalTime.of(11, 30), FormatStyle.SHORT, DateFormat.SHORT, Locale.UK}, {LocalTime.of(11, 30), FormatStyle.SHORT, DateFormat.SHORT, Locale.US}, {LocalTime.of(11, 30), FormatStyle.SHORT, DateFormat.SHORT, Locale.FRANCE}, {LocalTime.of(11, 30), FormatStyle.SHORT, DateFormat.SHORT, Locale.JAPAN}, {LocalTime.of(11, 30), FormatStyle.MEDIUM, DateFormat.MEDIUM, Locale.UK}, {LocalTime.of(11, 30), FormatStyle.MEDIUM, DateFormat.MEDIUM, Locale.US}, {LocalTime.of(11, 30), FormatStyle.MEDIUM, DateFormat.MEDIUM, Locale.FRANCE}, {LocalTime.of(11, 30), FormatStyle.MEDIUM, DateFormat.MEDIUM, Locale.JAPAN}, // these localized patterns include "z" which isn't available from LocalTime // {LocalTime.of(11, 30), FormatStyle.LONG, DateFormat.LONG, Locale.UK}, // {LocalTime.of(11, 30), FormatStyle.LONG, DateFormat.LONG, Locale.US}, // {LocalTime.of(11, 30), FormatStyle.LONG, DateFormat.LONG, Locale.FRANCE}, // {LocalTime.of(11, 30), FormatStyle.LONG, DateFormat.LONG, Locale.JAPAN}, // // {LocalTime.of(11, 30), FormatStyle.FULL, DateFormat.FULL, Locale.UK}, // {LocalTime.of(11, 30), FormatStyle.FULL, DateFormat.FULL, Locale.US}, // {LocalTime.of(11, 30), FormatStyle.FULL, DateFormat.FULL, Locale.FRANCE}, // {LocalTime.of(11, 30), FormatStyle.FULL, DateFormat.FULL, Locale.JAPAN}, }; }
Example 2
Source File: TCKLocalizedPrinterParser.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
@DataProvider(name="time") Object[][] data_time() { return new Object[][] { {LocalTime.of(11, 30), FormatStyle.SHORT, DateFormat.SHORT, Locale.UK}, {LocalTime.of(11, 30), FormatStyle.SHORT, DateFormat.SHORT, Locale.US}, {LocalTime.of(11, 30), FormatStyle.SHORT, DateFormat.SHORT, Locale.FRANCE}, {LocalTime.of(11, 30), FormatStyle.SHORT, DateFormat.SHORT, Locale.JAPAN}, {LocalTime.of(11, 30), FormatStyle.MEDIUM, DateFormat.MEDIUM, Locale.UK}, {LocalTime.of(11, 30), FormatStyle.MEDIUM, DateFormat.MEDIUM, Locale.US}, {LocalTime.of(11, 30), FormatStyle.MEDIUM, DateFormat.MEDIUM, Locale.FRANCE}, {LocalTime.of(11, 30), FormatStyle.MEDIUM, DateFormat.MEDIUM, Locale.JAPAN}, // these localized patterns include "z" which isn't available from LocalTime // {LocalTime.of(11, 30), FormatStyle.LONG, DateFormat.LONG, Locale.UK}, // {LocalTime.of(11, 30), FormatStyle.LONG, DateFormat.LONG, Locale.US}, // {LocalTime.of(11, 30), FormatStyle.LONG, DateFormat.LONG, Locale.FRANCE}, // {LocalTime.of(11, 30), FormatStyle.LONG, DateFormat.LONG, Locale.JAPAN}, // // {LocalTime.of(11, 30), FormatStyle.FULL, DateFormat.FULL, Locale.UK}, // {LocalTime.of(11, 30), FormatStyle.FULL, DateFormat.FULL, Locale.US}, // {LocalTime.of(11, 30), FormatStyle.FULL, DateFormat.FULL, Locale.FRANCE}, // {LocalTime.of(11, 30), FormatStyle.FULL, DateFormat.FULL, Locale.JAPAN}, }; }
Example 3
Source File: TCKLocalizedPrinterParser.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
@DataProvider(name="time") Object[][] data_time() { return new Object[][] { {LocalTime.of(11, 30), FormatStyle.SHORT, DateFormat.SHORT, Locale.UK}, {LocalTime.of(11, 30), FormatStyle.SHORT, DateFormat.SHORT, Locale.US}, {LocalTime.of(11, 30), FormatStyle.SHORT, DateFormat.SHORT, Locale.FRANCE}, {LocalTime.of(11, 30), FormatStyle.SHORT, DateFormat.SHORT, Locale.JAPAN}, {LocalTime.of(11, 30), FormatStyle.MEDIUM, DateFormat.MEDIUM, Locale.UK}, {LocalTime.of(11, 30), FormatStyle.MEDIUM, DateFormat.MEDIUM, Locale.US}, {LocalTime.of(11, 30), FormatStyle.MEDIUM, DateFormat.MEDIUM, Locale.FRANCE}, {LocalTime.of(11, 30), FormatStyle.MEDIUM, DateFormat.MEDIUM, Locale.JAPAN}, // these localized patterns include "z" which isn't available from LocalTime // {LocalTime.of(11, 30), FormatStyle.LONG, DateFormat.LONG, Locale.UK}, // {LocalTime.of(11, 30), FormatStyle.LONG, DateFormat.LONG, Locale.US}, // {LocalTime.of(11, 30), FormatStyle.LONG, DateFormat.LONG, Locale.FRANCE}, // {LocalTime.of(11, 30), FormatStyle.LONG, DateFormat.LONG, Locale.JAPAN}, // // {LocalTime.of(11, 30), FormatStyle.FULL, DateFormat.FULL, Locale.UK}, // {LocalTime.of(11, 30), FormatStyle.FULL, DateFormat.FULL, Locale.US}, // {LocalTime.of(11, 30), FormatStyle.FULL, DateFormat.FULL, Locale.FRANCE}, // {LocalTime.of(11, 30), FormatStyle.FULL, DateFormat.FULL, Locale.JAPAN}, }; }
Example 4
Source File: TCKLocalizedPrinterParser.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
@DataProvider(name="date") Object[][] data_date() { return new Object[][] { {LocalDate.of(2012, 6, 30), FormatStyle.SHORT, DateFormat.SHORT, Locale.UK}, {LocalDate.of(2012, 6, 30), FormatStyle.SHORT, DateFormat.SHORT, Locale.US}, {LocalDate.of(2012, 6, 30), FormatStyle.SHORT, DateFormat.SHORT, Locale.FRANCE}, {LocalDate.of(2012, 6, 30), FormatStyle.SHORT, DateFormat.SHORT, Locale.JAPAN}, {LocalDate.of(2012, 6, 30), FormatStyle.MEDIUM, DateFormat.MEDIUM, Locale.UK}, {LocalDate.of(2012, 6, 30), FormatStyle.MEDIUM, DateFormat.MEDIUM, Locale.US}, {LocalDate.of(2012, 6, 30), FormatStyle.MEDIUM, DateFormat.MEDIUM, Locale.FRANCE}, {LocalDate.of(2012, 6, 30), FormatStyle.MEDIUM, DateFormat.MEDIUM, Locale.JAPAN}, {LocalDate.of(2012, 6, 30), FormatStyle.LONG, DateFormat.LONG, Locale.UK}, {LocalDate.of(2012, 6, 30), FormatStyle.LONG, DateFormat.LONG, Locale.US}, {LocalDate.of(2012, 6, 30), FormatStyle.LONG, DateFormat.LONG, Locale.FRANCE}, {LocalDate.of(2012, 6, 30), FormatStyle.LONG, DateFormat.LONG, Locale.JAPAN}, {LocalDate.of(2012, 6, 30), FormatStyle.FULL, DateFormat.FULL, Locale.UK}, {LocalDate.of(2012, 6, 30), FormatStyle.FULL, DateFormat.FULL, Locale.US}, {LocalDate.of(2012, 6, 30), FormatStyle.FULL, DateFormat.FULL, Locale.FRANCE}, {LocalDate.of(2012, 6, 30), FormatStyle.FULL, DateFormat.FULL, Locale.JAPAN}, }; }
Example 5
Source File: TCKLocalizedPrinterParser.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
@DataProvider(name="time") Object[][] data_time() { return new Object[][] { {LocalTime.of(11, 30), FormatStyle.SHORT, DateFormat.SHORT, Locale.UK}, {LocalTime.of(11, 30), FormatStyle.SHORT, DateFormat.SHORT, Locale.US}, {LocalTime.of(11, 30), FormatStyle.SHORT, DateFormat.SHORT, Locale.FRANCE}, {LocalTime.of(11, 30), FormatStyle.SHORT, DateFormat.SHORT, Locale.JAPAN}, {LocalTime.of(11, 30), FormatStyle.MEDIUM, DateFormat.MEDIUM, Locale.UK}, {LocalTime.of(11, 30), FormatStyle.MEDIUM, DateFormat.MEDIUM, Locale.US}, {LocalTime.of(11, 30), FormatStyle.MEDIUM, DateFormat.MEDIUM, Locale.FRANCE}, {LocalTime.of(11, 30), FormatStyle.MEDIUM, DateFormat.MEDIUM, Locale.JAPAN}, // these localized patterns include "z" which isn't available from LocalTime // {LocalTime.of(11, 30), FormatStyle.LONG, DateFormat.LONG, Locale.UK}, // {LocalTime.of(11, 30), FormatStyle.LONG, DateFormat.LONG, Locale.US}, // {LocalTime.of(11, 30), FormatStyle.LONG, DateFormat.LONG, Locale.FRANCE}, // {LocalTime.of(11, 30), FormatStyle.LONG, DateFormat.LONG, Locale.JAPAN}, // // {LocalTime.of(11, 30), FormatStyle.FULL, DateFormat.FULL, Locale.UK}, // {LocalTime.of(11, 30), FormatStyle.FULL, DateFormat.FULL, Locale.US}, // {LocalTime.of(11, 30), FormatStyle.FULL, DateFormat.FULL, Locale.FRANCE}, // {LocalTime.of(11, 30), FormatStyle.FULL, DateFormat.FULL, Locale.JAPAN}, }; }
Example 6
Source File: TCKLocalizedPrinterParser.java From hottub with GNU General Public License v2.0 | 6 votes |
@DataProvider(name="time") Object[][] data_time() { return new Object[][] { {LocalTime.of(11, 30), FormatStyle.SHORT, DateFormat.SHORT, Locale.UK}, {LocalTime.of(11, 30), FormatStyle.SHORT, DateFormat.SHORT, Locale.US}, {LocalTime.of(11, 30), FormatStyle.SHORT, DateFormat.SHORT, Locale.FRANCE}, {LocalTime.of(11, 30), FormatStyle.SHORT, DateFormat.SHORT, Locale.JAPAN}, {LocalTime.of(11, 30), FormatStyle.MEDIUM, DateFormat.MEDIUM, Locale.UK}, {LocalTime.of(11, 30), FormatStyle.MEDIUM, DateFormat.MEDIUM, Locale.US}, {LocalTime.of(11, 30), FormatStyle.MEDIUM, DateFormat.MEDIUM, Locale.FRANCE}, {LocalTime.of(11, 30), FormatStyle.MEDIUM, DateFormat.MEDIUM, Locale.JAPAN}, // these localized patterns include "z" which isn't available from LocalTime // {LocalTime.of(11, 30), FormatStyle.LONG, DateFormat.LONG, Locale.UK}, // {LocalTime.of(11, 30), FormatStyle.LONG, DateFormat.LONG, Locale.US}, // {LocalTime.of(11, 30), FormatStyle.LONG, DateFormat.LONG, Locale.FRANCE}, // {LocalTime.of(11, 30), FormatStyle.LONG, DateFormat.LONG, Locale.JAPAN}, // // {LocalTime.of(11, 30), FormatStyle.FULL, DateFormat.FULL, Locale.UK}, // {LocalTime.of(11, 30), FormatStyle.FULL, DateFormat.FULL, Locale.US}, // {LocalTime.of(11, 30), FormatStyle.FULL, DateFormat.FULL, Locale.FRANCE}, // {LocalTime.of(11, 30), FormatStyle.FULL, DateFormat.FULL, Locale.JAPAN}, }; }
Example 7
Source File: TCKLocalizedPrinterParser.java From hottub with GNU General Public License v2.0 | 6 votes |
@DataProvider(name="date") Object[][] data_date() { return new Object[][] { {LocalDate.of(2012, 6, 30), FormatStyle.SHORT, DateFormat.SHORT, Locale.UK}, {LocalDate.of(2012, 6, 30), FormatStyle.SHORT, DateFormat.SHORT, Locale.US}, {LocalDate.of(2012, 6, 30), FormatStyle.SHORT, DateFormat.SHORT, Locale.FRANCE}, {LocalDate.of(2012, 6, 30), FormatStyle.SHORT, DateFormat.SHORT, Locale.JAPAN}, {LocalDate.of(2012, 6, 30), FormatStyle.MEDIUM, DateFormat.MEDIUM, Locale.UK}, {LocalDate.of(2012, 6, 30), FormatStyle.MEDIUM, DateFormat.MEDIUM, Locale.US}, {LocalDate.of(2012, 6, 30), FormatStyle.MEDIUM, DateFormat.MEDIUM, Locale.FRANCE}, {LocalDate.of(2012, 6, 30), FormatStyle.MEDIUM, DateFormat.MEDIUM, Locale.JAPAN}, {LocalDate.of(2012, 6, 30), FormatStyle.LONG, DateFormat.LONG, Locale.UK}, {LocalDate.of(2012, 6, 30), FormatStyle.LONG, DateFormat.LONG, Locale.US}, {LocalDate.of(2012, 6, 30), FormatStyle.LONG, DateFormat.LONG, Locale.FRANCE}, {LocalDate.of(2012, 6, 30), FormatStyle.LONG, DateFormat.LONG, Locale.JAPAN}, {LocalDate.of(2012, 6, 30), FormatStyle.FULL, DateFormat.FULL, Locale.UK}, {LocalDate.of(2012, 6, 30), FormatStyle.FULL, DateFormat.FULL, Locale.US}, {LocalDate.of(2012, 6, 30), FormatStyle.FULL, DateFormat.FULL, Locale.FRANCE}, {LocalDate.of(2012, 6, 30), FormatStyle.FULL, DateFormat.FULL, Locale.JAPAN}, }; }
Example 8
Source File: PippoGroovyTemplate.java From pippo with Apache License 2.0 | 5 votes |
protected Integer parseStyle(String style) { if ("full".equals(style)) { return DateFormat.FULL; } else if ("long".equals(style)) { return DateFormat.LONG; } else if ("short".equals(style)) { return DateFormat.SHORT; } else if ("medium".equals(style)) { return DateFormat.MEDIUM; } else { return -1; } }
Example 9
Source File: LocaleDateFormats.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
@DataProvider(name = "dateFormats" ) private Object[][] dateFormats() { return new Object[][] { //8080774 //Locale, Format type, year, month, date, expected result {localeEnSG, DateFormat.SHORT, 2015, 5, 6, "6/5/15"}, {localeEnSG, DateFormat.MEDIUM, 2015, 5, 6, "6 May, 2015"}, {localeEnSG, DateFormat.LONG, 2015, 5, 6, "6 May, 2015"}, {localeEnSG, DateFormat.FULL, 2015, 5, 6, "Wednesday, 6 May, 2015"} }; }
Example 10
Source File: BaseLocalizer.java From grammaticus with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Get time-only DateFormat based on style for output. * Local time zone. * * @return a DateFormat based on localizer's time zone and cached */ public DateFormat getTimeFormat(int style) { switch (style) { case DateFormat.SHORT: return getTimeFormat(); case DateFormat.MEDIUM: return getMediumTimeFormat(); case DateFormat.LONG: return getLongTimeFormat(); default: return getTimeFormat(); } }
Example 11
Source File: FormatTimeMethod.java From pippo with Apache License 2.0 | 5 votes |
protected Integer parseStyle(String style) { if ("full".equals(style)) { return DateFormat.FULL; } else if ("long".equals(style)) { return DateFormat.LONG; } else if ("short".equals(style)) { return DateFormat.SHORT; } else if ("medium".equals(style)) { return DateFormat.MEDIUM; } else { return -1; } }
Example 12
Source File: DateTimeFormatHelper.java From trimou with Apache License 2.0 | 5 votes |
protected Integer parseStyle(String style, MustacheTagInfo tagInfo) { if ("full".equals(style)) { return DateFormat.FULL; } else if ("long".equals(style)) { return DateFormat.LONG; } else if ("short".equals(style)) { return DateFormat.SHORT; } else if ("medium".equals(style)) { return DateFormat.MEDIUM; } else { throw unknownStyle(style, tagInfo); } }
Example 13
Source File: SakaiDateFormatProvider.java From sakai with Educational Community License v2.0 | 5 votes |
/** * Returns a date pattern with the given formatting style for the specified * locale. * * @param style the given date formatting style. * @param locale the desired locale. * @return a date pattern. * @throws IllegalArgumentException if <code>style</code> is invalid, or if * <code>locale</code> isn't available. * @throws NullPointerException if <code>locale</code> is <code>null</code>. */ protected String getDateFormatString(final int style, final Locale locale) throws IllegalArgumentException, NullPointerException { if (locale == null) { throw new NullPointerException("locale:null"); } else if (!SakaiLocaleServiceProviderUtil.isAvailableLocale(locale)) { throw new IllegalArgumentException("locale:" + locale.toString()); } String key; switch (style) { case DateFormat.SHORT: key = "DateFormat.SHORT"; break; case DateFormat.MEDIUM: key = "DateFormat.MEDIUM"; break; case DateFormat.LONG: key = "DateFormat.LONG"; break; case DateFormat.FULL: key = "DateFormat.FULL"; break; default: throw new IllegalArgumentException("style:" + style); } return SakaiLocaleServiceProviderUtil.getString(key, locale); }
Example 14
Source File: DateFormatter.java From spring-analysis-note with MIT License | 5 votes |
private int getStylePatternForChar(int index) { if (this.stylePattern != null && this.stylePattern.length() > index) { switch (this.stylePattern.charAt(index)) { case 'S': return DateFormat.SHORT; case 'M': return DateFormat.MEDIUM; case 'L': return DateFormat.LONG; case 'F': return DateFormat.FULL; case '-': return -1; } } throw new IllegalStateException("Unsupported style pattern '" + this.stylePattern + "'"); }
Example 15
Source File: FormatTimeExtension.java From pippo with Apache License 2.0 | 5 votes |
protected Integer parseStyle(String style) { if ("full".equals(style)) { return DateFormat.FULL; } else if ("long".equals(style)) { return DateFormat.LONG; } else if ("short".equals(style)) { return DateFormat.SHORT; } else if ("medium".equals(style)) { return DateFormat.MEDIUM; } else { return -1; } }
Example 16
Source File: SakaiDateFormatProvider.java From sakai with Educational Community License v2.0 | 5 votes |
/** * Returns a time pattern with the given formatting style for the specified * locale. * * @param style the given time formatting style. * @param locale the desired locale. * @return a time pattern. * @throws IllegalArgumentException if <code>style</code> is invalid, or if * <code>locale</code> isn't available. * @throws NullPointerException if <code>locale</code> is <code>null</code>. */ protected String getTimeFormatString(final int style, final Locale locale) throws IllegalArgumentException, NullPointerException { if (locale == null) { throw new NullPointerException("locale:null"); } else if (!SakaiLocaleServiceProviderUtil.isAvailableLocale(locale)) { throw new IllegalArgumentException("locale:" + locale.toString()); } String key; switch (style) { case DateFormat.SHORT: key = "TimeFormat.SHORT"; break; case DateFormat.MEDIUM: key = "TimeFormat.MEDIUM"; break; case DateFormat.LONG: key = "TimeFormat.LONG"; break; case DateFormat.FULL: key = "TimeFormat.FULL"; break; default: throw new IllegalArgumentException("style:" + style); } return SakaiLocaleServiceProviderUtil.getString(key, locale); }
Example 17
Source File: DateFormatter.java From java-technology-stack with MIT License | 5 votes |
private int getStylePatternForChar(int index) { if (this.stylePattern != null && this.stylePattern.length() > index) { switch (this.stylePattern.charAt(index)) { case 'S': return DateFormat.SHORT; case 'M': return DateFormat.MEDIUM; case 'L': return DateFormat.LONG; case 'F': return DateFormat.FULL; case '-': return -1; } } throw new IllegalStateException("Unsupported style pattern '" + this.stylePattern + "'"); }
Example 18
Source File: DateTimeFunctions.java From jasperreports with GNU Lesser General Public License v3.0 | 5 votes |
/** * This methods tries to convert a generic object into a java.util.Date instance. * Supported types are for now String, Long values (time millis) and Date subtypes * like for example java.sql.Date. */ private Date convertDateObject(Object dateObject){ if(dateObject==null){ if(log.isDebugEnabled()){ log.debug("The date object can not be null."); } return null; } else if(dateObject instanceof String){ // Try to convert using the different style for pattern. // We use MEDIUM as the first one because it is the DEFAULT int formatTypes[] = new int[]{DateFormat.MEDIUM, DateFormat.SHORT, DateFormat.LONG, DateFormat.FULL}; for(int formatType : formatTypes) { try { DateFormat df = DateFormat.getDateInstance(formatType, getReportLocale()); df.setTimeZone(getReportTimeZone()); return df.parse((String)dateObject); } catch (ParseException e) { if(log.isDebugEnabled()){ log.debug("Unable to parse the string as Date using the standard SimpleDateFormat."); } } } return null; } else if(dateObject instanceof Long){ Calendar cal = Calendar.getInstance(getReportTimeZone(), getReportLocale()); cal.setTimeInMillis((Long)dateObject); return cal.getTime(); } else if(dateObject instanceof Date){ return (Date)dateObject; } if(log.isDebugEnabled()){ log.debug("The specified object is not among the allowed types for Date conversion."); } return null; }
Example 19
Source File: LocaleDateFormats.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
@DataProvider(name = "dateFormats" ) private Object[][] dateFormats() { return new Object[][] { //8080774 //Locale, Format type, year, month, date, expected result {localeEnSG, DateFormat.SHORT, 2015, 5, 6, "6/5/15"}, {localeEnSG, DateFormat.MEDIUM, 2015, 5, 6, "6 May, 2015"}, {localeEnSG, DateFormat.LONG, 2015, 5, 6, "6 May, 2015"}, {localeEnSG, DateFormat.FULL, 2015, 5, 6, "Wednesday, 6 May, 2015"} }; }
Example 20
Source File: EthiopianTime.java From Time4A with Apache License 2.0 | 5 votes |
@Override public String getFormatPattern( DisplayStyle style, Locale locale ) { return ((style.getStyleValue() == DateFormat.SHORT) ? "h:mm a" : "h:mm:ss a"); }