How do I write a layout for NLog that outputs time with milliseconds like this 11:32:08:123?
I use ${date:format=yyyy-MM-dd HH\:mm\:ss} but I need more time precision in my logs.
${date:format=yyyy-MM-dd HH\:mm\:ss.fff}
According to the NLog documentation, you can use C# DateTime format string.
This is a pretty good reference for DateTime format strings: http://www.geekzilla.co.uk/View00FF7904-B510-468C-A2C8-F859AA20581F.htm
${longdate}
Another alternative to the format suggested by harriyott is to use the ${longdate} renderer. It should automatically give you the precision you need.
Another alternative solution is to use the ISO 8601 format '1998-02-23T14:23:05.555'. This format is independet of the languange of the sql server.
${date:format=yyyy-MM-ddTHH\:mm\:ss.fff}
Related
I have a requirement where I need the pattern ICU uses to format the given date/time.
For example: If I have something like DateFormat.getDateInstance(DateFormat.SHORT, en_US).format(currentDate) gives me 5/3/2015, then I need an API which can tell me that the pattern ICU4J internally using is d/M/yyyy.
I did figure out a solution, all you need to do is convert the DateFormat into a SimpleDateFormat and call toPattern().
((SimpleDateFormat)DateFormat.getDateInstance(DateFormat.SHORT, en_US)).toPattern() returns d/M/y which is what I almost needed.
I have noticed that the date and time fields being returned to me from the Nest API are not matching the format that the API documentation lists.
For my thermostat, I am getting the following for last_connection:
"last_connection": "2014-10-27T20:22:12.165Z"
But the API documentation lists it should be formatted as:
"last_connection": "2014-10-27T20:22:12+06:00"
Why is the Nest API returning milliseconds to me and why am I getting the character "Z" instead of the actual timezone offset that the date/time is coming from?
It looks like the example is incorrect with respect to the actual implementation. If you look at the API Reference you will see the time data is all in ISO 8601, which support both string types.
This also means you should likely use a library to support ISO 8601, rather than manually parsing the string if possible.
I have date string return by ServiceStack : 2013-08-25T12:06:32.8770000 but error when convert to date of Dart
DateTime.parse(mapAccount[Account.RECCREATED]);
it ok when call
DateTime.parse((mapAccount[Account.RECCREATED] as String).substring(0, 26));
Is there anyway to fix it. Thanks you.
Looks like the string don't match the internally used regular expression:
r'^([+-]?\d?\d\d\d\d)-?(\d\d)-?(\d\d)(?:[ T](\d\d)(?::?(\d\d)(?::?(\d\d)(.\d{1,6})?)?)? ?([zZ])?)?$'
But the regular expression doesn't support more that 6 digits for the milliseconds (and microseconds) part, but you supply 7 digits.
The documentation does not state which formats are supported, but gives some examples. They only state that they support a subset of ISO 8601.
Looks like your solution is the only one a the moment.
Not sure if this should be treaded as a bug, but if you think it is a bug, create a bug report here.
See the docs about DateTime.parse for more details. Looks like the problems with the parse function is already in the bug tracker.
I am using Talend Open Studio to fetch info from a DB to an XML file and then using XSLT on that.
There is a date field that comes into the XML as: 2013-02-13T16:49:51.733+0230, when I supply a Date Pattern: "yyyy-MM-dd'T'HH:mm:ss.SSSZ".
I believe SimpleDateFormat has this limitation of not able to deal with colon.
I need the colon in between the timezone value: +02:30. How can I achieve that? Is there a different Pattern String that I can use? If not, can I do it in my XSL Transform?
Function format-dateTime() looks for current-dateTime() format which needs colon between time zone HH:MM, in your case it is missing (0230). You should use another method to put colon between them:
let $x:= "2013-02-13T16:49:51.733+0230"
return concat(substring-before($x,'+'),'+',substring(substring-after($x,'+'),1,2),':',substring(substring-after($x,'+'),3,2))
output:
2013-02-13T16:49:51.733+02:30
i m just stuck with a vxml element in an ssml file in tropo. tropo does not recognize
interpret="time" and i have to put interpret="vxml:time".
But I need to also define the format attribute format:"hms12". so i write this:
<say-as interpret-as="vxml:time" format="hms12">243P</say-as> </s>
but it keeps pronouncing it like three integers.
i searched everywhere for the right syntax but couldn't find something.
I believe that is the default format for Tropo. Leave out the format attribute and make format your value as "0243p" for 2:43 PM, instead of "243P" as you have it. If you do not have your value in the exact format from the source of the data I would just convert it to this format rather than trying to force Tropo to conform to its format.