In R 3.3.3, using the package rJava (version 0.9-9), running on Linux (RHEL 6.9), I am encountering an error running the following piece of code to create a Java Date from an R string:
library(rJava)
rDateString <- "2016-01-01 10:00:00"
.jinit()
df <- .jnew("java/text/SimpleDateFormat", "yyyy-MM-dd HH:mm:ss")
pp <- .jnew("java/text/ParsePosition", as.integer(0))
d <- .jcall(df, "Ljava/util/Date", "parse", rDateString, pp)
This gives the following error:
Error in .jcall(df, "Ljava/util/Date", "parse", rDateString, pp) :
method parse with signature (Ljava/lang/String;Ljava/text/ParsePosition;)Ljava/util/Date not found
This confuses me, because this method should be available. Calling .jmethods
on my SimpleDateFormat object, results in (snip):
> .jmethods(df)
[5] "public java.util.Date java.text.SimpleDateFormat.parse(java.lang.String,java.text.ParsePosition)"
So, as far as I can tell, I'm complying to the parse
method signature, yet there is still an error. Can anyone shed some light as to what I am missing here? Much appreciated.
Missing semicolon (Ljava/util/Date
=> Ljava/util/Date;
):
d <- .jcall(df, "Ljava/util/Date;", "parse", rDateString, pp)
d
[1] "Java-Object{Fri Jan 01 10:00:00 CET 2016}"