Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

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

public class Main {
    /**
     * converts time to UTC format
     */
    public static String getHourFormatted(Date createdUTC) {

        Date dateServer = createdUTC;

        TimeZone.setDefault(TimeZone.getTimeZone("GMT"));
        Calendar cal = Calendar.getInstance(TimeZone.getDefault());
        Date dateGMT = cal.getTime();

        return normalDateFormat(dateServer);

    }

    public static String normalDateFormat(Date date) {
        SimpleDateFormat format = new SimpleDateFormat("MMMM dd, yyyy");
        return format.format(date);
    }
}