Welcome Serena Central users! CLICK HERE
The migration of the Serena Central community is currently underway. Be sure to read THIS MESSAGE to get your new login set up to access your account.
adaikalavan Absent Member.
Absent Member.
316 views

Parsing Time Zone +01:00

I have written a flex connector for a feed that captures the time but treats it only in mm/dd/yyyy format.

Since the log message time is actually of the format dd/mm/yyy I had to write my own override.

I am able to capture individual fields and then concatenate them and use the function __createOptionalTimeStampFromString to get a timestamp for

09/01/2017 14:36:57.000

and all Timezones are converted to the connector TimeZone.

but I also need to include the time zone in the log, i.e

09/01/2017 14:36:57.000+00:00

I used a Z for the time Zone but the connector kept reporting an issue with this.

I spent some time using

z

ZZ:ZZ

zz:zz 

but to no success.

Can someone tell me what can be done to accomodate the time Zone.

Here is the parser I wrote.....

note:

flexString1 and flexString2 are capturing

000    and      +00:00

########################################################################################################################

# Sample logs

#09/01/2017 14:36:57.000+00:00 || 7-PRO-X64 || PROCESS || 1532 || C:\Windows\System32\SearchProtocolHost.exe || 42ec9065d9bf266ade924b066c783a56 || "C:\Windows\system32\SearchProtocolHost.exe" Global\UsGthrFltPipeMssGthrPipe11_ Global\UsGthrCtrlFltPipeMssGthrPipe11 1 -2147483646 "Software\Microsoft\Windows Search" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT; MS Search 4.0 Robot)" "C:\ProgramData\Microsoft\Search\Data\Temp\usgthrsvc" "DownLevelDaemon"  || 2728 || Created || False || SYSTEM

#09/01/2017 14:36:57.000+01:00 || 7-PRO-X64 || PROCESS || 3136 || C:\Windows\System32\SearchFilterHost.exe || 52d56d1013d4f1b99102679314cc5325 || "C:\Windows\system32\SearchFilterHost.exe" 0 508 512 520 65536 516  || 2728 || Created || False || SYSTEM

#09/01/2017 14:37:04.000+00:00 || HATM-SRV16-X64 || PROCESS || 3032 || C:\Windows\System32\OpenWith.exe || feaeec585fea59a316dddd6c8505da8d || C:\Windows\system32\OpenWith.exe -Embedding || 652 || Created || False || Administrator

#09/01/2017 14:37:07.000+12:00 || HATM-SRV16-X64 || PROCESS || 5716 || C:\Windows\System32\wbem\WmiPrvSE.exe || d8e539426644a0f23cbf53dd0a5ee079 || C:\Windows\system32\wbem\wmiprvse.exe -Embedding || 652 || Destroyed || False || SYSTEM

########################################################################################################################

regex=(([\\d]+)\\/([\\d]+)\\/([\\d]+)[^\\S]([\\d]+\\:[\\d]+\\:[\\d]+)\\.([\\d]+)([^\\s]+).*)

#Tokens

token.count=7

token[0].name=v_String1

token[0].type=String

token[1].name=v_String2

token[1].type=String

token[2].name=v_String3

token[2].type=String

token[3].name=v_String4

token[3].type=String

token[4].name=v_String5

token[4].type=String

token[5].name=v_String6

token[5].type=String

token[6].name=v_String7

token[6].type=String

event.deviceVendor=__stringConstant("AAA")

event.deviceProduct=__stringConstant("BBBBBBBB")

event.message=v_String1

#event.deviceCustomDate1=__createOptionalTimeStampFromString(__concatenate(v_String2,"\",v_String3,"\",v_String4," ",v_String5,".",v_String6," ",v_String7),"dd\MM\yyyy HH:mm:ss.SSS z")

#event.deviceCustomDate2=__parseMutableTimeStamp(__concatenate(v_String2,"\",v_String3,"\",v_String4," ",v_String5,".",v_String6," ",v_String7),"dd\MM\yyyy HH:mm:ss.SSS+Z")

event.deviceCustomDate2=__createOptionalTimeStampFromString(__concatenate(v_String2,"\",v_String3,"\",v_String4," ",v_String5,".",v_String6," ",v_String7),"dd\MM\yyyy HH:mm:ss.SSS z")

event.flexString1=v_String6

event.flexString2=v_String7

######################################################################################################

thanks

Labels (2)
Tags (1)
0 Likes
1 Reply
rhope Acclaimed Contributor.
Acclaimed Contributor.

Re: Parsing Time Zone +01:00

It doesn't like the colon in the Timezone string, and you appear to not have all the fields in your concatenated string.  Try this:

event.deviceCustomDate1=__createOptionalTimeStampFromString(__concatenate(v_String1,"",v_String2,"",v_String3," ",v_String4,".",v_String5,""," ",__replaceAll(v_String6,"\:","")),"ddMMyyyy HH\:mm\:ss.SSS Z")

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.