Highlighted
Absent Member.
Absent Member.
682 views

Parsing failed: JavaException: java.lang.RuntimeException


Hi,

when i use custom collector to read mssql table, sentinel system
log prompt from web UI:

Parsing failed: JavaException: java.lang.RuntimeException:
java.text.ParseException: Unparseable date: "2014-01-03 17:03:00.0";
input:

collector use query statement to retrieve datetime from REQUEST_TM
field: 2014-01-03 17:03:00.000

i use following codes in release.js to transmit datetime to
setObserverEventTime but apear Unparseable date message, why?

var detstring =
this.RXMap.col_REQUEST_TM.replace(/(\d{4})\-(\d+)\-(\d+)
(\d+\:\d+\:\d+)\.\d+/, "$2/$3/$1 $4 GMT");
var dt = new Date(detstring);
e.setObserverEventTime(dt);
instance.SEND_EVENT = true;

BR
Steve zeng


--
steve_zeng
------------------------------------------------------------------------
steve_zeng's Profile: https://forums.netiq.com/member.php?userid=3875
View this thread: https://forums.netiq.com/showthread.php?t=50291

0 Likes
2 Replies
Highlighted
Absent Member.
Absent Member.


steve_zeng;242151 Wrote:
> Hi,
>
> when i use custom collector to read mssql table, sentinel system
> log prompt from web UI:
>
> Parsing failed: JavaException: java.lang.RuntimeException:
> java.text.ParseException: Unparseable date: "2014-01-03 17:03:00.0";
> input:
>
> collector use query statement to retrieve datetime from REQUEST_TM
> field: 2014-01-03 17:03:00.000
>
> i use following codes in release.js to transmit datetime to
> setObserverEventTime but apear Unparseable date message, why?
>
> var detstring =
> this.RXMap.col_REQUEST_TM.replace(/(\d{4})\-(\d+)\-(\d+)
> (\d+\:\d+\:\d+)\.\d+/, "$2/$3/$1 $4 GMT");
> var dt = new Date(detstring);
> e.setObserverEventTime(dt);
> instance.SEND_EVENT = true;
>
> BR
> Steve zeng


The date that you formatted with replace is still not one that the JS
date function can understand.


--
brandon.langley
------------------------------------------------------------------------
brandon.langley's Profile: https://forums.netiq.com/member.php?userid=350
View this thread: https://forums.netiq.com/showthread.php?t=50291

0 Likes
Highlighted
Absent Member.
Absent Member.


Hi Steve,

Brandon is right, your date is not coming through correctly. What I
think is happening is that your regex is not matching, so what 'replace'
returns is just the original string, which includes the terminal ".0"
which the Date parser does not understand.

All you really need to do is trim off the terminal ".0", so I would
suggest:

e.setObserverEventTime(new
Date(this.RXMAP.col_REQUEST_TM.substr(0,this.RXMAP.col_REQUEST_TM.length
- 2));

The '2' there might not be quite right - zero-indexes always confuse me
😉 - but tweak it and that should work.

One note: there's an ambiguity about the order of Month-Day in a date
like this (which is formats like ISO8661 exist); if you need to you can
use Date.parseExact() instead and specify the input format of the date
in the proper order.


--
DCorlette
------------------------------------------------------------------------
DCorlette's Profile: https://forums.netiq.com/member.php?userid=323
View this thread: https://forums.netiq.com/showthread.php?t=50291

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.