美文网首页
安卓日期i18n方法

安卓日期i18n方法

作者: 奇松_ca45 | 来源:发表于2018-05-18 11:35 被阅读0次

    Date now = new Date();

            TextView chineseTime = (TextView)findViewById(R.id.chineseShortDate);

            TextView chineseTimeMedium = (TextView)findViewById(R.id.chineseMediumDate);

            TextView preciseTextChinese = (TextView)findViewById(R.id.preciseDateChinese);

            DateFormat chineseDateShort = DateFormat.getDateInstance(DateFormat.SHORT, Locale.CHINESE);

            DateFormat chineseDateMedium = DateFormat.getDateInstance(DateFormat.MEDIUM, Locale.CHINESE);

            SimpleDateFormat preciseChineseFormat = new SimpleDateFormat("MMMM yyyy", Locale.CHINESE);

            chineseTime.setText("Chinese default short:"+chineseDateShort.format(now));

            chineseTimeMedium.setText("Chinese default medium:"+chineseDateMedium.format(now));

            preciseTextChinese.setText("Chinese MMMM yyyy:"+preciseChineseFormat.format(now));

            DateFormat englishDateShort = DateFormat.getDateInstance(DateFormat.SHORT, Locale.ENGLISH);

            DateFormat englishDateMedium = DateFormat.getDateInstance(DateFormat.MEDIUM, Locale.ENGLISH);

            SimpleDateFormat preciseEnglishFormat = new SimpleDateFormat("MMMM yyyy", Locale.ENGLISH);

            TextView englishDateShortText = (TextView)findViewById(R.id.englishShortDate);

            TextView englishDateMediumText = (TextView)findViewById(R.id.englishMediumDate);

            TextView preciseTextEnglish = (TextView)findViewById(R.id.preciseDateEnlish);

            englishDateShortText.setText("English default short:"+englishDateShort.format(now));

            englishDateMediumText.setText("English default medium:"+englishDateMedium.format(now));

            preciseTextEnglish.setText("English MMMM yyyy:"+preciseEnglishFormat.format(now));

        android:layout_width="match_parent"

        android:orientation="vertical"

        android:layout_height="wrap_content">

            android:id="@+id/chineseShortDate"

            android:layout_width="wrap_content"

            android:text="Chinese time"

            android:layout_height="wrap_content" />

            android:id="@+id/chineseMediumDate"

            android:layout_width="wrap_content"

            android:text="Chinese time"

            android:layout_height="wrap_content" />

            android:id="@+id/preciseDateChinese"

            android:layout_width="wrap_content"

            android:text="presize Date"

            android:layout_height="wrap_content" />

            android:id="@+id/englishShortDate"

            android:layout_width="wrap_content"

            android:text="Englsih time"

            android:layout_height="wrap_content" />

            android:id="@+id/englishMediumDate"

            android:layout_width="wrap_content"

            android:text="Englsih time"

            android:layout_height="wrap_content" />

            android:id="@+id/preciseDateEnlish"

            android:layout_width="wrap_content"

            android:text="presize Date"

            android:layout_height="wrap_content" />

    相关文章

      网友评论

          本文标题:安卓日期i18n方法

          本文链接:https://www.haomeiwen.com/subject/xixgdftx.html