如何在XSLT 1.0中格式化DATE [英] How to format DATE in XSLT 1.0
本文介绍了如何在XSLT 1.0中格式化DATE的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我搜索了一下,但找不到答案.
I searched a bit but couldn't find the answer.
我想将当前日期和格式设置为YYYYMMDD
I want to get current date and format to YYYYMMDD
我不能按照我的要求使用EXSLT.
I cannot use EXSLT as per my requirements.
推荐答案
一个非常简单的内联C#脚本Functoid可能看起来像这样:
A very simple Inline C# Script Functoid could look like this:
public string MyDateFormat(string dateValue)
{
string result = String.Empty;
string outputFormat = "{0:yyyyMMdd}";
DateTime parsed;
if (DateTime.TryParse(dateValue, out parsed))
{
result = String.Format(outputFormat, parsed);
}
else
{
result = String.Format(outputFormat, DateTime.MinValue);
}
return result;
}
对于类似的问题,我创建了一个外部程序集,该程序集可以指定CultureInfo
来解析输入的DateTime字符串,还可以将输出格式的字符串提交为仿函数输入参数.
For a similar problem I created a External Assembly which will allow to specify CultureInfo
for parsing the input DateTime string and also submit the output format string as a functoid input parameter.
这篇关于如何在XSLT 1.0中格式化DATE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文