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

public class Main {
    private static final String DATE_SERVER_FORMAT = "yyyy-MM-dd HH:mm:ss";
    private static final String DATE_LOCAL_FORMAT = "dd MMMM yyyy";

    public static String changeDateFormat(String createDate) {

        String date = "";
        SimpleDateFormat input = new SimpleDateFormat(DATE_SERVER_FORMAT);
        SimpleDateFormat output = new SimpleDateFormat(DATE_LOCAL_FORMAT);

        Date formatDate;

        try {

            formatDate = input.parse(createDate);
            date = output.format(formatDate);

        } catch (ParseException pe) {
            pe.printStackTrace();
        }

        return date;
    }
}