[
https://issues.apache.org/jira/browse/NIFI-7911?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17242676#comment-17242676
]
DEOM Damien commented on NIFI-7911:
-----------------------------------
I've found the solution,:
import java.text.DateFormat
import java.text.SimpleDateFormat
import org.apache.commons.io.IOUtils
import java.nio.charset.StandardCharsets
SimpleDateFormat date_format=new SimpleDateFormat("dd-MM-yyyy HH:mm:ss",
Locale.FRANCE);
*{color:#ff8b00}date_format.setTimeZone(TimeZone.getTimeZone("Europe/Paris")){color}*
def date_str = date_format.parse("05-10-2020
23:10:00").format("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", TimeZone.getTimeZone("UTC"))
log.error(date_str)
> Groovy Executescript: fail to convert timezone
> ----------------------------------------------
>
> Key: NIFI-7911
> URL: https://issues.apache.org/jira/browse/NIFI-7911
> Project: Apache NiFi
> Issue Type: Bug
> Affects Versions: 1.12.0, 1.11.4
> Reporter: DEOM Damien
> Priority: Major
>
> Nifi's execute script fails to properly convert timezones in Groovy
> The following code gives the correct result on my local machine (groovy
> console 3.0.1): *2020-10-05T21:10:00.000Z*
>
>
> {code:java}
> import java.text.DateFormat
> import java.text.SimpleDateFormat
> import org.apache.commons.io.IOUtils
> import java.nio.charset.StandardCharsets
> SimpleDateFormat date_format=new SimpleDateFormat("dd-MM-yyyy HH:mm:ss",
> Locale.FRANCE);
> def date_str = date_format.parse("05-10-2020
> 23:10:00").format("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", TimeZone.getTimeZone("UTC"))
> log.error(date_str)
> {code}
>
>
> On Nifi, I get *2020-10-05T23:10:00.000Z*
>
--
This message was sent by Atlassian Jira
(v8.3.4#803005)