Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import java.text.ParseException;
import java.text.SimpleDateFormat;

import java.util.Locale;
import java.util.TimeZone;

public class Main {

    public static String getLocalDateTimeFromUTCDateTime(String UTCDateTime) {
        java.util.Date nowDate = null;
        String UTCDate = null;
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.getDefault());
        try {
            nowDate = format.parse(UTCDateTime);
            UTCDate = format.format(nowDate.getTime() + TimeZone.getDefault().getRawOffset());
        } catch (ParseException e) {
            e.printStackTrace();
        }

        return UTCDate;

    }
}