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

import java.util.TimeZone;

public class Main {
    public static String getScheduleFormattedDate(String date) {
        java.util.Calendar calendar = getCalendarFromStringDate(date);
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");

        return format.format(calendar.getTime());
    }

    public static java.util.Calendar getCalendarFromStringDate(String dateString) {
        java.util.Calendar calendar = java.util.Calendar.getInstance();
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
        format.setTimeZone(TimeZone.getTimeZone("ETC/UTC"));

        try {
            Date date = format.parse(dateString);
            // System.out.println("Date ->" + date);
            calendar.setTime(date);
            return calendar;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
}