忍者ブログ
よくわからないことを調べて解説してみるブログ。

2024

0426
×

[PR]上記の広告は3ヶ月以上新規記事投稿のないブログに表示されています。新しい記事を書く事で広告が消えます。

2015

0607
Format
┗ DateFormat
 ┗ SimpleDateFormat
┗ NumberFormat
 ┗ DecimalFormat
 ┗ ChoiceFormat
┗ MessageFormat

DateFormat,NumberFormatは、ロケール対応のみしており、細かな表現方法は指定できない。

SimpleDateFormat,DecimalFormatは、細かな表現方法が指定可能である。

ChoiceFormatは、数値について範囲ごとの表現を指定可能である。例えば、


		double[] limits = { 1, 2, 3, 4, 5, 6, 7 };
		String[] dayOfWeekNames = { "Sun", "Mon", "Tue", "Wed", "Thur", "Fri", "Sat" };
		ChoiceFormat form = new ChoiceFormat(limits, dayOfWeekNames);
		ParsePosition status = new ParsePosition(0);
		for (double i = 0.0; i <= 8.0; ++i) {
			status.setIndex(0);
			System.out.println(i + " -> " + form.format(i) + " -> "
					+ form.parse(form.format(i), status));
		}

実行結果
0.0 -> Sun -> 1.0
1.0 -> Sun -> 1.0
2.0 -> Mon -> 2.0
3.0 -> Tue -> 3.0
4.0 -> Wed -> 4.0
5.0 -> Thur -> 5.0
6.0 -> Fri -> 6.0
7.0 -> Sat -> 7.0
8.0 -> Sat -> 7.0

拍手[0回]

PR
Post your Comment
Name:
Title:
Font:
Mail:
URL:
Comment:
Pass: Vodafone絵文字 i-mode絵文字 Ezweb絵文字
プロフィール
HN:
たんてーくん
性別:
非公開
フリーエリア
最新CM
[09/25 http://2017.bblbuy.com]
[09/24 http://www.japanform.com]
[09/23 http://www.japanform.com]
[09/22 http://www.japanform.com]
[09/21 http://2017.bblbuy.com]
ブログ内検索
忍者ブログ [PR]
* Template by TMP