Lehel44 commented on code in PR #5888:
URL: https://github.com/apache/nifi/pull/5888#discussion_r848493771
##########
nifi-docs/src/main/asciidoc/expression-language-guide.adoc:
##########
@@ -2299,30 +2299,58 @@ chaining together the two functions:
`${date:toDate('MM-dd-yyyy'):format('yyyy/M
[.function]
=== toInstant
-*Description*: [.description]#Converts a String or Number into an Instant data
type, based on the format specified by the argument. The argument
+*Description*: [.description]#Converts a String or Number into an Instant data
type, based on the format specified by the argument. In case of
+String format nanosecond precision date parsing is supported. The argument
must be a String that is a valid Java DateTimeFormatter syntax. The Subject is
expected to be a String that is formatted
-according the argument or a number which represents the datetime in
milliseconds. The datetime will be evaluated using the local time zone unless
-specified in the second optional argument.#
+according the argument or a number which represents the datetime in
milliseconds. The datetime will be evaluated using the
+time zone specified in the second argument.#
*Subject Type*: [.subject]#String or Number#
*Arguments*:
- [.argName]#_format_# : [.argDesc]#The current format to use when parsing the
Subject, in the Java DateTimeFormatter syntax.#
-- [.argName]#_time zone_# : [.argDesc]#Optional argument that specifies the
time zone to use when parsing the Subject, in the Java TimeZone syntax.#
+- [.argName]#_time zone_# : [.argDesc]#Required argument that specifies the
time zone to use when parsing the Subject, in the Java TimeZone syntax.#
*Return Type*: [.returnType]#Instant#
-*Examples*: If the attribute "time" has the value "2014/12/31 15:36:03.264Z"
then the expression `${time:toDate("yyyy/MM/dd HH:mm:ss.SSS'Z'", "GMT")}` will
result in a Date data type for
+*Examples*: If the attribute "time" has the value "2014/12/31 15:36:03.264Z"
then the expression `${time:toInstant("yyyy/MM/dd HH:mm:ss.SSS'Z'", "GMT")}`
will result in an Instant data type for
15:36:03.264 GMT on December 31, 2014.
Often, this function is used in conjunction with the <<formatInstant>>
function to change the format of a date/time. For example,
-if the attribute "instant" has the value "12-24-2014 12:06:59" and we want to
change the format to "2014/12/24", we can do so by
-chaining together the two functions: `${date:toDate('MM-dd-yyyy
HH:mm:ss'):format('yyyy/MM/dd')}`.
+if the attribute "dateTime" has the value "12-24-2014 12:06:59" and we want to
change the format to "2014/12/24", we can do so by
+chaining together the two functions: `${dateTime:toInstant('MM-dd-yyyy
HH:mm:ss', 'GMT'):formatInstant('yyyy/MM/dd', 'GMT')}`.
+[.function]
+=== toMicros
+
+*Description*: [.description]#Converts an Instant Subject into a Number with
microsecond precision#
+
+*Subject Type*: [.subject]#Instant#
+
+*Arguments*: No arguments
+
+*Return Type*: [.returnType]#Number#
+
+*Examples*: If the "dateTime" attribute has the value of "2022/03/18
10:22:27.678234567", then the Expression
+`${dateTime:toInstant('yyyy/MM/dd HH:mm:ss.SSSSSSSSS',
'America/New_York'):toMicros()}` converts the Instant value of
+the attribute to 1647613347678234 microseconds since epoch.
+[.function]
+=== toNanos
+
+*Description*: [.description]#Converts an Instant Subject into a Number with
nanosecond precision#
+
+*Subject Type*: [.subject]#Instant#
+
+*Arguments*: No arguments
+
+*Return Type*: [.returnType]#Number#
+*Examples*: If the "dateTime" attribute has the value of "2022/03/18
10:22:27.678234567", then the Expression
+`${dateTime:toInstant('yyyy/MM/dd HH:mm:ss.SSSSSS',
'America/New_York'):toNanos()}` converts the Instant value of
Review Comment:
According to the DateTimeFormatter
[documentation](https://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html)
_S_ means fraction-of-second. _n_ works also. I changed it to 9 S from 6.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]