Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.text.ParseException;
import java.text.SimpleDateFormat;

import java.util.Date;

import java.util.TimeZone;

public class Main {
    static SimpleDateFormat sdfgmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    static SimpleDateFormat sdfest = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

    public static String formatJsonDate(String jd) {
        sdfgmt.setTimeZone(TimeZone.getTimeZone("GMT"));
        sdfest.setTimeZone(TimeZone.getTimeZone("US/Eastern"));

        String stripped = jd.substring(0, 19).replace('T', ' ');
        Date date = new Date();

        try {
            date = sdfgmt.parse(stripped);
        } catch (ParseException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        String result = sdfest.format(date);

        return result;
    }
}