﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
13376	Use Java 8 Date API (JSR 310)?	simon04	team	"I did some performance tests for timestamp parsing.

{{{
#!java
package org.openstreetmap.josm.tools.date;

import java.time.Instant;
import java.time.ZonedDateTime;
import java.util.Random;
import java.util.stream.IntStream;
import java.util.stream.Stream;

import org.junit.Test;

public class DateUtilsPerformanceTest {

    Stream<String> getTestData() {
        final Random random = new Random(23528390L);
        return IntStream.generate(() -> 0)
                .limit(4_000_000)
                .mapToObj(x -> String.format(""%04d-%02d-%02dT%02d:%02d:%02dZ"",
                        2000 + random.nextInt(20),
                        1 + random.nextInt(12),
                        1 + random.nextInt(28),
                        random.nextInt(24),
                        random.nextInt(60),
                        random.nextInt(60)
                ));
    }

    @Test
    public void testDateUtils() throws Exception {
        getTestData().forEach(DateUtils::fromString);
    }

    @Test
    public void testZonedDateTime() throws Exception {
        getTestData().forEach(ZonedDateTime::parse);
    }

    @Test
    public void testInstant() throws Exception {
        getTestData().forEach(Instant::parse);
    }
}
}}}

The results:

||DateUtils.parse using Calendar.set (as is now)||14s 769ms||
||DateUtils.parse using ZonedDateTime.of (see patch)||13s 388ms||
||ZonedDateTime.parse||26s 620ms||
||Instant.parse||22s 222ms||

So, the current `DateUtil` is quite performant :)."	enhancement	closed	normal	16.12	Core		fixed	java8 jsr310 performance timestamp	
