1.8.8 Create LocalDateTime from LinkedTreeMap String

Discussion in 'Spigot Plugin Development' started by illuminator3, Feb 21, 2020.

  1. So basically I've got this String {last={date={month=2.0, year=2020.0, day=21.0}, time={hour=18.0, nano=2.97E8, minute=2.0, second=58.0}}, times=0.0}. And I want to turn it into a LocalDateTime Object. How would I do this?
  2. use a library to read the json string, then create a new Date object from it...
  3. Impossible, because it isn't a JSON string, and they're longs not integers.
  4. Sorry it looks like json from a glance. Where are you getting this from? Why not serialize the data in a form you can process?
  5. Code (Java):
            final JsonStatsAPI api = new JsonStatsAPI();
            final UUID uuid = UUID.randomUUID();

            System.out.println("uuid: " + uuid + "\n\n");

            final LocalDateTime time = LocalDateTime.now();

            api.set(uuid, "last", new JsonStatsAPI.Value<>(time.minusNanos(time.getNano())));

            final String serialize = api.serialize();

            final JsonStatsAPI newApi = JsonStatsAPI.deserialize(serialize);