0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

【Apex】OutputText内で日付を表示する際の曜日をVF側だけで日本語表記できないかやってみた。

Posted at

まずは以前にもご紹介したOutputTextの日付のフォーマット化を使って、

想定通りの日付を表示させます。

public class DateTimeController {
    public Date dayOfWeek { get; set; }
    
    public DateTimeController(){
        dayOfWeek = system.today();
    }
}
<apex:page controller="DateTimeController">
    <apex:pageMessages id="message"/>
    <apex:form >
        <apex:pageBlock >
            <apex:outputText value="{0,date,yyyy/MM/dd}">
                <apex:param value="{!dayOfWeek}"/>
            </apex:outputText>
        </apex:pageBlock>
    </apex:form>
</apex:page>

すると表示はこのようになります。
スクリーンショット 2019-11-06 6.44.31.png

では次に

<apex:outputText value="{0,date,yyyy/MM/dd E}">
   <apex:param value="{!dayOfWeek}"/>
</apex:outputText>

フォーマット部分にEを加えてみます。

スクリーンショット 2019-11-06 6.46.29.png

すると短い形式の曜日がでましたが、英語表記ですね。。。

ここでjavaのフォーマットを見直してみると、引数にロケールを渡してあげると
良いみたいなんですが。

salesforceだとしっかり怒られます。

スクリーンショット 2019-11-06 6.55.35.png

ちなみに試してみたのは下記の形式です。

<apex:outputText value="{0,date,yyyy/MM/dd E,Locale}">
<apex:outputText value="{0,date,yyyy/MM/dd E,Locale.Japan}">

やっぱりApex側で番号取得して曜日に変換するやり方しかないんだろうか。。。

今回は答えが見つからずでした。

引き続き模索してみようと思います。

profile

生まれも育ちも大阪の浪速中の浪速っ子が30才未経験からITエンジニアとして生きるブログもやってます。
よかったらみてください:muscle_tone2:

PVアクセスランキング にほんブログ村

0
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?