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.TimeZone;

public class Main {
    public static SimpleDateFormat getServerDateTimeInTimezone(String timezone) {

        SimpleDateFormat format = new SimpleDateFormat("EEE, d MMM yyyy");
        if (timezone == null || timezone.isEmpty()) {
            format.setTimeZone(TimeZone.getDefault());
        } else {
            format.setTimeZone(TimeZone.getTimeZone("GMT+" + timezone));
        }
        return format;
    }
}