public class controller_formatted_datetime
{
public DateTime date_time { get; set; } // コンポーネントの属性タグから日付/時間型の値を読み取るプロパティ
public String defined_format { get; set;} // コンポーネントの属性タグから文字列型の値を読み取るプロパティ
public String getFormattedDatetime(){
if (date_time == null)
{
return '';
}
else {
if (defined_format == null) {
return date_time.format(); // ユーザの場所およびタイムゾーンで完全な日付/時間型を返します
}
else
{
return date_time.format(defined_format,'PST'); // IST、CST などのタイムゾーンを指定します
}
}
}
}
2.コンポーネントを作成します。<apex:component access="global" controller="controller_formatted_datetime">{!FormattedDatetime}
<apex:attribute assignTo="{!date_time}" description="The DateTime value to be rendered" name="date_time_value" type="DateTime"></apex:attribute>
<apex:attribute assignTo="{!defined_format}" description="The optional format to use for the DateTime value to be rendered" name="date_time_format" type="String"></apex:attribute>
</apex:component>
<messaging:emailTemplate subject="Testing DateTime Format" recipientType="Contact" >
<messaging:plainTextEmailBody >
Formatted: <c:VFEmailTempComp date_time_value="{!NOW()}" date_time_format="EEE MMM d kk:mm:ss z yyyy" />
</messaging:plainTextEmailBody>
</messaging:emailTemplate>
return date_time.format(defined_format,'<Your Time Zone>'); // <あなたのタイムゾーン> を現在必要とするタイムゾーンに置き換えます
000385603

We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.