简体   繁体   English

Apex中的日期格式转换

[英]Date Format Conversion In Apex

I have a date item ' Order_TCD' in the form. 我在表单中有一个日期项目' Order_TCD'

My requirement is when user enters Order_TCD it should be in the format: 我的要求是,当用户输入Order_TCD时,其格式应为:

DD-MON-YYYY HH:MIPM, 

But the data in the report should appear in the format DD-MON-YY. 但是报告中的数据应以DD-MON-YY.格式显示DD-MON-YY.

DD-MON-YYYY HH:MIPM DD-MON-YYYY HH:MIPM

If Order_TCD is DATE data type, then while inserting the row you need to use TO_DATE and required format mask . 如果Order_TCD是DATE数据类型,则在插入行时,您需要使用TO_DATE和所需的格式mask You must specify the user to enter the date in the format DD-MON-YYYY HH:MIPM . 您必须指定用户以DD-MON-YYYY HH:MIPM格式输入日期。 And you need to handle it as: 您需要按以下方式处理它:

TO_DATE('05-MAY-2015 11:05AM','DD-MON-YYYY HH:MIPM')

But the data in the report should appear in the format DD-MON-YY. 但是报告中的数据应以DD-MON-YY格式显示。

To display the date in your desired format, you need to use TO_CHAR . 要以所需格式显示日期,您需要使用TO_CHAR

For example, 例如,

TO_CHAR(Order_TCD, 'DD-MON-YY')

To set the format mask on the (datepicker!) item, simply edit the item and go to the "Settings" section. 要在(日期选择器!)项上设置格式掩码,只需编辑该项并转到“设置”部分。 You can enter the format mask there. 您可以在此处输入格式掩码。

项目格式遮罩

To display with another format mask in the report, you can set the format mask in the column attributes. 要在报表中显示另一种格式掩码,可以在列属性中设置格式掩码。 Example here for an interactive report. 此处为交互式报告的示例。
报告列格式掩码

You could also apply the mask on the column in the source SQL of course. 当然,您也可以在源SQL的列上应用掩码。 Also note that you can set a global application date format mask in the globalization options of the application. 另请注意,您可以在应用程序的全球化选项中设置全局应用程序日期格式掩码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM