static void datetime2str()
{
str resultstr;
utcDateTime result;
resultstr = DateTimeUtil::toFormattedStr(result,321, DateDay::Digits2, DateSeparator::Hyphen, DateMonth::Digits2, DateSeparator::Hyphen, DateYear::Digits4, TimeSeparator::Colon, TimeSeparator::Colon, DateFlags::None);
info(resultstr);
}
The function date2str take following parameters :
1- the date .
2- the date style dmy or ymd or....etc .
3- number of digits for day .
4- separator
5- number of digits for month.
6- separator
7- number of digits for year.
================================================================
static void string2datetime()
{
System.Globalization.CultureInfo culture
= System.Globalization.CultureInfo::get_InvariantCulture();
str resultstr;
utcDateTime result;
try
{
result= System.DateTime::ParseExact(
"2007-05-28 X 23:59:04",
"yyyy-MM-dd X HH:mm:ss",
culture);
info(strFmt("%1",result));
}
catch (Exception::CLRError)
{
throw error(AifUtil::getClrErrorMessage());
}
}
https://community.dynamics.com/ax/f/33/t/125802
============================================================
https://msdn.microsoft.com/en-us/library/cc553823.aspx
{
str resultstr;
utcDateTime result;
resultstr = DateTimeUtil::toFormattedStr(result,321, DateDay::Digits2, DateSeparator::Hyphen, DateMonth::Digits2, DateSeparator::Hyphen, DateYear::Digits4, TimeSeparator::Colon, TimeSeparator::Colon, DateFlags::None);
info(resultstr);
}
The function date2str take following parameters :
1- the date .
2- the date style dmy or ymd or....etc .
3- number of digits for day .
4- separator
5- number of digits for month.
6- separator
7- number of digits for year.
================================================================
static void string2datetime()
{
System.Globalization.CultureInfo culture
= System.Globalization.CultureInfo::get_InvariantCulture();
str resultstr;
utcDateTime result;
try
{
result= System.DateTime::ParseExact(
"2007-05-28 X 23:59:04",
"yyyy-MM-dd X HH:mm:ss",
culture);
info(strFmt("%1",result));
}
catch (Exception::CLRError)
{
throw error(AifUtil::getClrErrorMessage());
}
}
https://community.dynamics.com/ax/f/33/t/125802
============================================================
https://msdn.microsoft.com/en-us/library/cc553823.aspx
static void JobDateTimeGlobalMarshal(Args _args) { System.DateTime netDttm; utcdatetime xppDttm; str xppString; ; xppDttm = 2007-06-05T23:22:21; // ISO standard format. // Convert X++ to .NET. netDttm = Global::utcDateTime2SystemDateTime(xppDttm); // Convert .NET to X++. xppDttm = Global::CLRSystemDateTime2UtcDateTime(netDttm); xppString = DateTimeUtil::toStr(xppDttm); info("xppDttm: " + xppString); }
===========================================================================
static void FormatUtcdatetime(Args _args)
{
System.Globalization.CultureInfo culture
= System.Globalization.CultureInfo::get_InvariantCulture();
str resultstr,frstpart,secondpart;
utcDateTime result;
result = DateTimeUtil::getSystemDateTime();
//info(strFmt("%1",result));
resultstr = DateTimeUtil::toFormattedStr(result,321, DateDay::Digits2, DateSeparator::Hyphen, DateMonth::Digits2, DateSeparator::Hyphen, DateYear::Digits4, TimeSeparator::Colon, TimeSeparator::Colon, DateFlags::None);
frstpart = subStr(resultstr,0,10);
secondpart = subStr(resultstr,11,9);
resultstr = frstpart+"T"+"09:20:06";//+"09:16:30";
result = DateTimeUtil::parse(frstpart+"T"+"09:20:06");
//info(secondpart);
// info(frstpart+"T"+secondpart);
try
{
/* result= System.DateTime::ParseExact(
"2007-05-28T23:59:04",
"yyyy'-'MM'-'dd'T'HH':'mm':'ss",
culture);*/
result= System.DateTime::ParseExact(
"2007-05-28 X 23:59:04",
"yyyy-MM-dd X HH:mm:ss",
culture);
//result = DateTimeUtil::parse(resultstr);
info(strFmt("%1",result));
}
catch (Exception::CLRError)
{
throw error(AifUtil::getClrErrorMessage());
}
//yyyy'-'MM'-'dd'T'HH':'mm':'ss
}
https://msdn.microsoft.com/en-us/library/system.globalization.datetimeformatinfo.sortabledatetimepattern(v=vs.100).aspx
https://msdn.microsoft.com/en-us/library/system.datetime.parseexact(v=vs.110).aspx
No comments:
Post a Comment