import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

public class LocalDateTimeTest {

    public void testParseAndOf() {
        final long COUNT = 1000000;
        final String DATE_TIME = "20151127192939";
        final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");

        long start = System.currentTimeMillis();
        for (int i = 1; i < COUNT; i++) {
            LocalDateTime.parse(DATE_TIME, FORMATTER);
        }
        System.out.println((System.currentTimeMillis() - start) + "ms : LocalDateTime.parse(...)");

        start = System.currentTimeMillis();
        for (int i = 1; i < COUNT; i++) {
            int year = Integer.valueOf(DATE_TIME.substring(0, 4));
            int month = Integer.valueOf(DATE_TIME.substring(4, 6));
            int day = Integer.valueOf(DATE_TIME.substring(6, 8));
            int hour = Integer.valueOf(DATE_TIME.substring(8, 10));
            int minute = Integer.valueOf(DATE_TIME.substring(10, 12));
            int sec = Integer.valueOf(DATE_TIME.substring(12));
            LocalDateTime.of(year, month, day, hour, minute, sec);
        }
        System.out.println((System.currentTimeMillis() - start) + "ms : LocalDateTime.of(...)");
    }
    
    public static void main (String[] args){
    	new LocalDateTimeTest().testParseAndOf();
    }
}
