Java Code Examples for java.text.DateFormat.LONG

The following are Jave code examples for showing how to use LONG of the java.text.DateFormat class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: openjdk-jdk10   File: TCKLocalizedPrinterParser.java   Source Code and License Vote up 7 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 2
Project: q-mail   File: QuoteHelper.java   Source Code and License Vote up 6 votes
/**
 * Extract the date from a message and convert it into a locale-specific
 * date string suitable for use in a header for a quoted message.
 *
 * @return A string with the formatted date/time
 */
static String getSentDateText(Resources resources, Message message) {
    try {
        final int dateStyle = DateFormat.LONG;
        final int timeStyle = DateFormat.LONG;
        Date date = message.getSentDate();

        DateFormat dateFormat;
        if (QMail.hideTimeZone()) {
            dateFormat = DateFormat.getDateTimeInstance(dateStyle, timeStyle, Locale.ROOT);
            dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
        } else {
            Locale locale = resources.getConfiguration().locale;
            dateFormat = DateFormat.getDateTimeInstance(dateStyle, timeStyle, locale);
        }
        return dateFormat.format(date);
    } catch (Exception e) {
        return "";
    }
}
 
Example 3
Project: myfaces-trinidad   File: DateTimeConverter.java   Source Code and License Vote up 6 votes
private static final int _getTimeStyle(String timeStyle)
{
  if ("default".equals(timeStyle))
  {
    return (DateFormat.DEFAULT);
  }
  else if ("short".equals(timeStyle))
  {
    return (DateFormat.SHORT);
  }
  else if ("medium".equals(timeStyle))
  {
    return (DateFormat.MEDIUM);
  }
  else if ("long".equals(timeStyle))
  {
    return (DateFormat.LONG);
  }
  else if ("full".equals(timeStyle))
  {
    return (DateFormat.FULL);
  }
  else
    throw new IllegalStateException(_LOG.getMessage(
      "INVALID_TIME_STYLE", timeStyle));
}
 
Example 4
Project: jdk8u-jdk   File: TCKLocalizedPrinterParser.java   Source Code and License Vote up 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
Project: myfaces-trinidad   File: DateTimeConverter.java   Source Code and License Vote up 5 votes
/**
 * <p>Return the style constant for the specified style name.</p>
 * If invalid throw IllegalStateException.
 *
 * @param dateStyle Name of the date style for which to return a constant
 *
 */
private static final int _getDateStyle(String dateStyle)
{
  if (dateStyle.equals("shortish"))
  {
    return _SHORTISH;
  }
  else if (dateStyle.equals("default"))
  {
    return (DateFormat.DEFAULT);
  }
  else if (dateStyle.equals("short"))
  {
    return (DateFormat.SHORT);
  }
  else if (dateStyle.equals("medium"))
  {
    return (DateFormat.MEDIUM);
  }
  else if (dateStyle.equals("long"))
  {
    return (DateFormat.LONG);
  }
  else if (dateStyle.equals("full"))
  {
    return (DateFormat.FULL);
  }
  else
    throw new IllegalStateException(_LOG.getMessage(
      "INVALID_DATE_STYLE", dateStyle));
}
 
Example 6
Project: BittrexApi   File: DefaultDateTypeAdapterTest.java   Source Code and License Vote up 5 votes
@Test
public void testDateSerialization() throws Exception {
    int dateStyle = DateFormat.LONG;
    DefaultDateTypeAdapter dateTypeAdapter = new DefaultDateTypeAdapter(Date.class, dateStyle);
    DateFormat formatter = DateFormat.getDateInstance(dateStyle, Locale.US);
    Date currentDate = new Date();

    String dateString = dateTypeAdapter.toJson(currentDate);
    assertEquals(toLiteral(formatter.format(currentDate)), dateString);
}
 
Example 7
Project: lams   File: DateFormatter.java   Source Code and License Vote up 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 8
Project: lams   File: DateUtil.java   Source Code and License Vote up 5 votes
/**
    * Equivalent of <LAMS:Date value="value" type="date|time|both"/>. Use for processing a date to send to the client
    * via JSON. Locale comes from request.getLocale();
    *
    * @param value
    * @param type
    *            TYPE_BOTH (both data and time), TYPE_DATE or TYPE_TIME
    * @param locale
    * @return
    */
   public static String convertToStringForJSON(Date value, Integer style, Integer type, Locale locale) {

HttpSession ss = SessionManager.getSession();
UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER);
TimeZone tz = user.getTimeZone();

int dateStyle, timeStyle;
switch (style) {
    case DateFormat.SHORT:
	dateStyle = DateFormat.SHORT;
	timeStyle = DateFormat.SHORT;
	break;
    case DateFormat.FULL:
	dateStyle = DateFormat.LONG;
	timeStyle = DateFormat.FULL;
	break;
    default:
	dateStyle = DateFormat.LONG;
	timeStyle = DateFormat.MEDIUM;
}

DateFormat df = null;
switch (type) {
    case TYPE_DATE:
	df = DateFormat.getDateInstance(dateStyle, locale);
	break;
    case TYPE_TIME:
	df = DateFormat.getTimeInstance(timeStyle, locale);
	break;
    default:
	df = DateFormat.getDateTimeInstance(dateStyle, timeStyle, locale);
}

if (tz != null) {
    df.setTimeZone(tz);
}

return df.format(value);
   }
 
Example 9
Project: jdk8u-jdk   File: LocaleDateFormats.java   Source Code and License Vote up 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
Project: openjdk-jdk10   File: LocaleDateFormats.java   Source Code and License Vote up 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 11
Project: parabuild-ci   File: DateTitle.java   Source Code and License Vote up 2 votes
/**
 * Creates a new chart title that displays the current date in the default
 * (LONG) format for the locale, positioned to the bottom right of the 
 * chart.
 * <P>
 * The color will be black in 12 point, plain Helvetica font (maps to Arial
 * on Win32 systems without Helvetica).
 */
public DateTitle() {
    this(DateFormat.LONG);
}
 
Example 12
Project: parabuild-ci   File: DateTitle.java   Source Code and License Vote up 0 votes
/**
 * Creates a new chart title that displays the current date in the default
 * (LONG) format for the locale, positioned to the bottom right of the chart.
 * <P>
 * The color will be black in 12 point, plain Helvetica font (maps to Arial
 * on Win32 systems without Helvetica).
 */
public DateTitle() {

    this(DateFormat.LONG);

}