Java Code Examples for java.text.DateFormat.DEFAULT

The following are Jave code examples for showing how to use DEFAULT 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: 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 2
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 3
Project: odoo-work   File: GsonBuilder.java   Source Code and License Vote up 5 votes
private void addTypeAdaptersForDate(String datePattern, int dateStyle, int timeStyle,
    List<TypeAdapterFactory> factories) {
  DefaultDateTypeAdapter dateTypeAdapter;
  if (datePattern != null && !"".equals(datePattern.trim())) {
    dateTypeAdapter = new DefaultDateTypeAdapter(datePattern);
  } else if (dateStyle != DateFormat.DEFAULT && timeStyle != DateFormat.DEFAULT) {
    dateTypeAdapter = new DefaultDateTypeAdapter(dateStyle, timeStyle);
  } else {
    return;
  }

  factories.add(TreeTypeAdapter.newFactory(TypeToken.get(Date.class), dateTypeAdapter));
  factories.add(TreeTypeAdapter.newFactory(TypeToken.get(Timestamp.class), dateTypeAdapter));
  factories.add(TreeTypeAdapter.newFactory(TypeToken.get(java.sql.Date.class), dateTypeAdapter));
}
 
Example 4
Project: lams   File: GsonBuilder.java   Source Code and License Vote up 5 votes
private void addTypeAdaptersForDate(String datePattern, int dateStyle, int timeStyle,
    List<TypeAdapterFactory> factories) {
  DefaultDateTypeAdapter dateTypeAdapter;
  if (datePattern != null && !"".equals(datePattern.trim())) {
    dateTypeAdapter = new DefaultDateTypeAdapter(datePattern);
  } else if (dateStyle != DateFormat.DEFAULT && timeStyle != DateFormat.DEFAULT) {
    dateTypeAdapter = new DefaultDateTypeAdapter(dateStyle, timeStyle);
  } else {
    return;
  }

  factories.add(TreeTypeAdapter.newFactory(TypeToken.get(Date.class), dateTypeAdapter));
  factories.add(TreeTypeAdapter.newFactory(TypeToken.get(Timestamp.class), dateTypeAdapter));
  factories.add(TreeTypeAdapter.newFactory(TypeToken.get(java.sql.Date.class), dateTypeAdapter));
}