SE Asia Standard Timezone showing excluded date exclusion in parsing date format

I try with a different time zone in the date that everything works fine, but SE Asia Standard Time is not parsed with a full date showing the exception of the exceptional date.

String date="Sun Jan 18 2015 22:11:44 GMT+0700 (SE Asia Standard Time)";
        SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM dd yyyy HH:mm:ss 'GMT'Z (zzzz)");
        try{
            System.out.println(new Timestamp(sdf.parse(date).getTime()));
        }catch(Exception e){
            e.printStackTrace();
        }
+4
source share
2 answers

Looks like in Java this time zone is called "Indochina Time"

I think the time zone name does not need to parse the correct date, because you also have a time offset in your string. So removing the timezone name from the string should do this.

public static void main(String[] args) {
    String date = "Sun Jan 18 2015 22:11:44 GMT+0700 (SE Asia Standard Time)";

    date = date.substring(0, date.indexOf("("));
    SimpleDateFormat sdf = new SimpleDateFormat(
            "EEE MMM dd yyyy HH:mm:ss 'GMT'Z", Locale.ENGLISH);
    try {
        System.out.println(new Timestamp(sdf.parse(date).getTime()));
    } catch (Exception e) {
        e.printStackTrace();
    }
}
+1
source

"SE Asia Standard Time" . GMT + 7 :

public static void main(String[] args) {
    Arrays.asList(TimeZone.getAvailableIDs()).stream()
            .map(TimeZone::getTimeZone)
            .filter(zone -> zone.getRawOffset() == 7 * 60 * 60 * 1000)
            .forEach(zone -> System.out.printf("%-20s  %s\n", zone.getID(), zone.getDisplayName()));
}
Antarctica/Davis      Davis Time
Asia/Bangkok          Indochina Time
Asia/Ho_Chi_Minh      Indochina Time
Asia/Hovd             Hovd Time
Asia/Jakarta          West Indonesia Time
Asia/Krasnoyarsk      Krasnoyarsk Time
Asia/Novokuznetsk     Krasnoyarsk Time
Asia/Phnom_Penh       Indochina Time
Asia/Pontianak        West Indonesia Time
Asia/Saigon           Indochina Time
Asia/Vientiane        Indochina Time
Etc/GMT-7             GMT+07:00
Indian/Christmas      Christmas Island Time
VST                   Indochina Time
+1

All Articles