# LocalDateTime Error

**URL:** <https://discourse.processing.org/t/localdatetime-error/11086>\
**Category:** Processing for Android\
**Created:** [May 9, 2019, 7:51pm UTC](https://discourse.processing.org/t/localdatetime-error/11086 "2019-05-09T19:51:23Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Americanjoghurt](https://avatars.discourse-cdn.com/v4/letter/a/b38774/32.png) [@Americanjoghurt](https://discourse.processing.org/u/Americanjoghurt)\
**Post date:** [May 9, 2019, 7:51pm UTC](https://discourse.processing.org/t/localdatetime-error/11086/1 "2019-05-09T19:51:23Z")

</div>

Hi,  
I have the problem, that each Time I want to send my code with java.time.LocalDateTime includet it throws an Excepiton. Code without any Libarys works just fine. Want’s the Problem und how can I solve it?

---

<div class="post-metadata">

**Author:** ![akenaton](https://avatars.discourse-cdn.com/v4/letter/a/a88e4f/32.png) [@akenaton](https://discourse.processing.org/u/akenaton)\
**Post date:** [May 10, 2019, 8:18am UTC](https://discourse.processing.org/t/localdatetime-error/11086/2 "2019-05-10T08:18:46Z")

</div>

@Americanjoghurt ===  
what is the exception???  
can you put some code which reproduces the error?

---

<div class="post-metadata">

**Author:** ![Americanjoghurt](https://avatars.discourse-cdn.com/v4/letter/a/b38774/32.png) [@Americanjoghurt](https://discourse.processing.org/u/Americanjoghurt)\
**Post date:** [May 10, 2019, 9:35pm UTC](https://discourse.processing.org/t/localdatetime-error/11086/3 "2019-05-10T21:35:00Z")

</div>

```auto
import java.time.LocalDateTime;

void setup() {
  fullScreen();
  background(255, 100, 0);
}

void draw() {
  Timer t = new Timer();

public class Timer {

  boolean x;
  LocalDateTime Opentimer;
  LocalDateTime acttimer;
  public Timer() {

    Opentimer = LocalDateTime.of(2019, 5, 12, 12, 0, 0);
    acttimer = LocalDateTime.now();
    x = ueberschritten(acttimer, Opentimer);
  }
  public boolean ueberschritten(LocalDateTime a, LocalDateTime b) {
    if (a.isAfter(b)) return true;
    return false;
  }
  public String Ausgabe(LocalDateTime a, LocalDateTime b) {
    int Day = b.getDayOfMonth() - a.getDayOfMonth();
    int Hour = b.getHour() -a.getHour();
    int Minute = b.getMinute() - a.getMinute();
    int sec = b.getSecond() - a.getSecond();
    if (sec < 0) {
      sec = sec +60;
      Minute--;
    }
    if (Minute < 0) {
      Minute = 60 +Minute;
      Hour--;
    }
    if (Hour < 0)
    { 
      Hour = Hour +24;
      Day--;
    }
    return "Noch "+Day+ " Tage " + Hour+" Stunden " +Minute + "Minuten und " + sec + " Sekunden !!";
  }

```

```auto
Exception: 
java.lang.NoClassDefFoundError: Failed resolution of: Ljava/time/LocalDateTime;
	at processing.test.muttertagtest.Muttertagtest$Timer.<init>(Muttertagtest.java:51)
	at processing.test.muttertagtest.Muttertagtest.draw(Muttertagtest.java:29)
	at processing.core.PApplet.handleDraw(PApplet.java:1855)
	at processing.core.PSurfaceNone.callDraw(PSurfaceNone.java:476)
	at processing.core.PSurfaceNone$AnimationThread.run(PSurfaceNone.java:516)
Caused by: java.lang.ClassNotFoundException: Didn't find class "java.time.LocalDateTime" on path: DexPathList[[zip file "/data/app/processing.test.muttertagtest-2/base.apk"],nativeLibraryDirectories=[/data/app/processing.test.muttertagtest-2/lib/arm, /system/lib, /vendor/lib]]
	at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
	... 5 more

```

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [May 10, 2019, 9:37pm UTC](https://discourse.processing.org/t/localdatetime-error/11086/4 "2019-05-10T21:37:54Z")

</div>

Please format your code with \</\> when posting to the forum.

Also, your draw and Timer are missing their closing }

FWIW the example code runs fine in PDE Java mode with those corrections.

---

<div class="post-metadata">

**Author:** ![akenaton](https://avatars.discourse-cdn.com/v4/letter/a/a88e4f/32.png) [@akenaton](https://discourse.processing.org/u/akenaton)\
**Post date:** [May 11, 2019, 8:57am UTC](https://discourse.processing.org/t/localdatetime-error/11086/5 "2019-05-11T08:57:44Z")

</div>

@Americanjoghurt ===  
-as @jeremydouglass pointed out there are two missing brackets in your code  
-as for the error it s probably caused by the fact that java.Time was added only for API 26 (Oreo)  
-Anyway you can easily get hour and date with android using Calendar and creating some simple function:

```auto
import java.util.Locale;
import java.text.SimpleDateFormat;
import java.util.Calendar;

```

///////

```auto
void setup(){
String dateHeure = quelleDate();
println(dateHeure);
}

```

```auto
public static String quelleDate() {
        Calendar c = Calendar.getInstance();
        SimpleDateFormat sdf = new SimpleDateFormat("dd MMMM yyyy - hh mm ", Locale.FRENCH);
        String strDate = sdf.format(c.getTime());
        // System.out.println("aujourdhui =======" +strDate);
        return strDate;
    }

```
