Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.util.Calendar;
import java.util.Date;

import java.util.TimeZone;

public class Main {
    public static String getMonth(final Date date) {
        if (date != null) {
            Calendar calendar = Calendar.getInstance();
            TimeZone timeZone = TimeZone.getTimeZone("GMT+8");
            calendar.setTimeZone(timeZone);
            calendar.setTime(date);
            return String.valueOf(calendar.get(Calendar.MONTH) + 1);
        }
        return "0";
    }
}