Code example for SimpleDateFormat

Methods: format, setTimeZone

0
    private CommonUtils() { 
        // nothing to do 
    } 
 
    public static String formatForUtcTime(final Date date) {
        final DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
        dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
        return dateFormat.format(date);
    } 
 
    /** 
     * Check whether the object is null or not. If it is, throw an exception and 
     * display the message. 
     * 
     * @param object  the object to check. 
     * @param message the message to display if the object is null. 
     */ 
    public static void assertNotNull(final Object object, final String message) {
        if (object == null) {
            throw new IllegalArgumentException(message);
        }