Here you can find the source of parseDateTime(String yyyymmdd, String hhmmss)
public static ZonedDateTime parseDateTime(String yyyymmdd, String hhmmss)
//package com.java2s; //License from project: Open Source License import java.time.LocalDateTime; import java.time.ZoneId; import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; public class Main { public static ZonedDateTime parseDateTime(String yyyymmdd, String hhmmss) { return parseDateTime(yyyymmdd, hhmmss, ZoneId.systemDefault()); }//from ww w . jav a2 s .c om public static ZonedDateTime parseDateTime(String yyyymmdd) { return parseDateTime(yyyymmdd, "00:00:00"); } public static ZonedDateTime parseDateTime(String yyyymmdd, String hhmmss, String timezone) { return parseDateTime(yyyymmdd, hhmmss, determineTimeZoneId(timezone)); } public static ZonedDateTime parseDateTime(String yyyymmdd, String hhmmss, ZoneId timezone) { if (yyyymmdd == null) return null; return LocalDateTime.parse(yyyymmdd + "T" + hhmmss, DateTimeFormatter.ISO_LOCAL_DATE_TIME).atZone(timezone); } public static ZoneId determineTimeZoneId(String zoneId) { try { return ZoneId.of(zoneId); } catch (Exception e) {//NOSONAR return ZoneId.systemDefault(); } } }