import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;

class Main {
    public static void main(String[] args) throws Exception {
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z");
        formatter.setTimeZone(TimeZone.getTimeZone("UTC"));
        
        System.out.println("Formatting a date");
        
        Date now = new Date();
        System.out.println(formatter.format(now));
        
        System.out.println("Parsing a date");
        
        String s = "2022-04-12 11:28:42 UTC";
        System.out.println(formatter.parse(s));
    }
}

Embed on website

To embed this program on your website, copy the following code and paste it into your website's HTML: