There are two problems:
1) ZonedDateTime.parse method parse only strings that obey the ISO_ZONED_DATE_TIME format, description of how it looks you can find here:
https://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html#ISO_ZONED_DATE_TIME
In order to parse your format you have to create your own dateTimeFormatter.
This formatter can look like this
DateTimeFormatter formatter = new DateTimeFormatterBuilder()
.parseCaseInsensitive()
.append(DateTimeFormatter.ISO_LOCAL_DATE)
.appendLiteral('T')
.append(DateTimeFormatter.ISO_LOCAL_TIME)
.appendZoneId()
.toFormatter();
This formatter would work if you would use standart zones like GMT, UTC etc..
Problem is that HST is not standard format for Zone and is not supported. You can see supported time zones via:
System.out.println(ZoneId.getAvailableZoneIds());
If you still want to use HST zone you have to add ZoneRulesProvider for your custom zone like this:
ZoneRulesProvider.registerProvider(new ZoneRulesProvider() {
@Override
protected Set<String> provideZoneIds() {
return Collections.singleton("HST");
}
@Override
protected ZoneRules provideRules(String zoneId, boolean forCaching) {
return ZoneRules.of(ZoneOffset.ofHours(10));
}
@Override
protected NavigableMap<String, ZoneRules> provideVersions(String zoneId) {
TreeMap map = new TreeMap<>();
map.put("HST",ZoneRules.of(ZoneOffset.ofHours(10)));
return map;
}
});
DateTimeFormatter formatter = new DateTimeFormatterBuilder()
.parseCaseInsensitive()
.append(DateTimeFormatter.ISO_LOCAL_DATE)
.appendLiteral('T')
.append(DateTimeFormatter.ISO_LOCAL_TIME)
.appendZoneId()
.toFormatter();
ZonedDateTime timestamp = ZonedDateTime.parse("2018-10-29T12:00:12.456HST", formatter);
System.out.println(timestamp);
THis should work.