Skip to content

TimeUtil can not convert "yyyy-MM-dd'T'HH:mm:ssZ" to Long in Scala. #324

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ddpaimon opened this issue May 25, 2017 · 1 comment
Closed

Comments

@ddpaimon
Copy link

When I try to do this:

println(TimeUtil.fromInfluxDBTimeFormat("2016-10-31T16:52:20Z") == 1477932740000L)

I got exception:

Exception in thread "main" java.lang.RuntimeException: unexpected date format
	at org.influxdb.impl.TimeUtil.fromInfluxDBTimeFormat(TimeUtil.java:88)
	at com.xxx.app$.delayedEndpoint$com$bwsw$pulse$views$app$1(xxx.scala:59)
	at com.xxx.app$delayedInit$body.apply(xxx.scala:23)
	at scala.Function0.apply$mcV$sp(Function0.scala:34)
	at scala.Function0.apply$mcV$sp$(Function0.scala:34)
	at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12)
	at scala.App.$anonfun$main$1$adapted(App.scala:76)
	at scala.collection.immutable.List.foreach(List.scala:389)
	at scala.App.main(App.scala:76)
	at scala.App.main$(App.scala:74)
	at com.xxx.app$.main(xxx.scala:23)
	at com.xxx.app.main(xxx.scala)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
Caused by: java.text.ParseException: Unparseable date: "16:52:20"
	at java.text.DateFormat.parse(DateFormat.java:366)
	at org.influxdb.impl.TimeUtil.fromInfluxDBTimeFormat(TimeUtil.java:86)
	... 16 more
@fmachado
Copy link
Contributor

fmachado commented Jul 1, 2017

@ddpaimon please take a look into my comment and why you should avoid using TimeUtil.fromInfluxDBTimeFormat.

To fix your issue, pass a TimeUnit parameter when querying InfluxDB and use your own date formatter. If this works for you, please close this ticket.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants