/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

import java.time.*;
import java.time.temporal.*;
import java.time.format.*;

// By Basil Bourque. 
// Example code for a Question & Answer at Stack Overflow.
// http://stackoverflow.com/a/44011744/642706

/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
	public static void main (String[] args) throws java.lang.Exception
	{

        String input = "Tue, 16 May 2017 13:02:16 GMT" ;
        
        // Built-in formatter.
        DateTimeFormatter f = DateTimeFormatter.RFC_1123_DATE_TIME ;
        ZonedDateTime zdt = ZonedDateTime.parse( input , f ) ;

        System.out.println( "input: " + input ) ;
        System.out.println( "zdt.toString(): " + zdt ) ;
        
        // Custom formatter
        DateTimeFormatter f2 = DateTimeFormatter.ofPattern( "EEE, dd MMM yyyy HH:mm:ss z", Locale.ENGLISH ) ;
        ZonedDateTime zdt2 = ZonedDateTime.parse( input , f2 ) ;
        
        System.out.println( "zdt2.toString(): " + zdt2 ) ;

	}
}