Calendar problem

Discussion in 'Spigot Plugin Development' started by JustCedric, Jun 9, 2016.

  1. Hi guys,

    I get an error when this code executes..
    If someone dies I save the date exactly 1 day later so for example a player dies on 09-06-2016 19:00 the date in the config will be 10-06-2016 19:00 and I want to check if the current date is after the date in the config, but I get this error

    Code (Text):
    Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("Europe/Amsterdam"));
                    DateFormat dateFormat = new SimpleDateFormat("dd-mm-yyyy HH:mm:ss");
                    String death_end = instance.playerConfig.getString(UUID + ".die_date");
                    Date death = null;
                    try {
                        death = dateFormat.parse(death_end);
                    } catch (ParseException e) {
                    if (cal.getTime().after(death)) {
                        instance.playerConfig.set(UUID + ".die_date", null);
                        instance.saveYml(instance.playerConfig, instance.playerYml);
    Code (Text):
            at java.text.SimpleDateFormat.parse( ~[?:1.8.0_72]
            at java.text.DateFormat.parse( ~[?:1.8.0_72]
            at$ ~[?:?]
            at ~[spigot-1.9.4.jar:git-Spigot-4af49dc-c5e9a16]
            at org.bukkit.craftbukkit.v1_9_R2.scheduler.CraftScheduler.mainThreadHeartbeat( [spigot-1.9.4.jar:git-Spigot-4af49dc-c5e9a16]
            at net.minecraft.server.v1_9_R2.MinecraftServer.D( [spigot-1.9.4.jar:git-Spigot-4af49dc-c5e9a16]
            at net.minecraft.server.v1_9_R2.DedicatedServer.D( [spigot-1.9.4.jar:git-Spigot-4af49dc-c5e9a16]
            at net.minecraft.server.v1_9_R2.MinecraftServer.C( [spigot-1.9.4.jar:git-Spigot-4af49dc-c5e9a16]
            at [spigot-1.9.4.jar:git-Spigot-4af49dc-c5e9a16]
            at [?:1.8.0_72]
  2. NullPointerException: Most likely instance.playerConfig.getString(UUID + ".die_date"); either Instance or the config or the String is null.
  3. Thanks I dont get any errors rn but for some reason it gets executed when the current date is not after the date in the config?

    This is the date that gets put into config:
    die_date: 10-16-2016 19:16:19
    and it's not that date but it still gets executed..
  4. No idea, try some rubber duck debugging, and try some other methods.