1

Next thing:

java.lang.NoSuchMethodError: 
java.util.Date.from(Ljava/time/Instant;)Ljava/util/Date;

its running on desktop but not deployed on mobile..

Thanks for any suggestion..

tonimaroni
  • 1,062
  • 10
  • 19

1 Answers1

2

Most of the java.util.Date class works on mobile (Android and iOS). However there a few cases that are not available.

On Android or iOS if you try

Date date = Date.from(Instant.now());

that refers to the Java 8 static method Date.from(Instant), you'll get the exception you mentioned:

W System.err: Caused by: java.lang.NoSuchMethodError: No static method from(Ljava/time/Instant;)Ljava/util/Date; in class Ljava/util/Date; or its super classes (declaration of 'java.util.Date' appears in /system/framework/core-oj.jar)

To solve this issue, you can use the usual constructor instead, which is in turn what the static method uses:

// Android, iOS
Date date = new Date(Instant.now().toEpochMilli()));

Alternatively you can use the new java.time package.

José Pereda
  • 44,311
  • 7
  • 104
  • 132
  • Thank you again!! Is there a doc pointing out which are not available maybe? – tonimaroni Nov 24 '16 at 14:24
  • Check the documentation for JavaFXPorts [here](http://docs.gluonhq.com/javafxports/) and for Gluon Mobile [here](http://docs.gluonhq.com/charm/4.1.0/). Also check this [question](http://stackoverflow.com/questions/36538796/which-java-distribution-level-does-gluon-mobile-javafx-expose-for-ios-and-a). – José Pereda Nov 24 '16 at 14:31