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.Date;
import java.util.Locale;
import java.util.TimeZone;

public class Main {
    public static String convertCurrentTimeToGmt(String format) {
        final SimpleDateFormat dateFormatGmt = new SimpleDateFormat(format, Locale.getDefault());
        dateFormatGmt.setTimeZone(TimeZone.getTimeZone("GMT"));
        return dateFormatGmt.format(new Date());
    }
}