Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

import java.util.Calendar;
import java.util.GregorianCalendar;

import java.util.TimeZone;

public class Main {
    public static long convertTime(long timestamp, String fromTimeZone, String toTimeZone) {
        Calendar fromCal = new GregorianCalendar(TimeZone.getTimeZone(fromTimeZone));
        fromCal.setTimeInMillis(timestamp);
        Calendar toCal = new GregorianCalendar(TimeZone.getTimeZone(toTimeZone));
        toCal.setTimeInMillis(fromCal.getTimeInMillis());
        return toCal.getTimeInMillis();
    }
}