當前位置: 首頁>>代碼示例>>Java>>正文


Java DateFormat.MEDIUM屬性代碼示例

本文整理匯總了Java中java.text.DateFormat.MEDIUM屬性的典型用法代碼示例。如果您正苦於以下問題:Java DateFormat.MEDIUM屬性的具體用法?Java DateFormat.MEDIUM怎麽用?Java DateFormat.MEDIUM使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在java.text.DateFormat的用法示例。


在下文中一共展示了DateFormat.MEDIUM屬性的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: _getTimeStyle

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));
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:26,代碼來源:DateTimeConverter.java

示例2: data_date

@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},
    };
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:24,代碼來源:TCKLocalizedPrinterParser.java

示例3: data_time

@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},
        };
    }
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:25,代碼來源:TCKLocalizedPrinterParser.java

示例4: _getDateStyle

/**
 * <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));
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:37,代碼來源:DateTimeConverter.java

示例5: getStylePatternForChar

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 + "'");
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:12,代碼來源:DateFormatter.java

示例6: convertToStringForJSON

/**
    * 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);
   }
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:49,代碼來源:DateUtil.java

示例7: dateFormats

@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"}
    };
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:11,代碼來源:LocaleDateFormats.java


注:本文中的java.text.DateFormat.MEDIUM屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。