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;

public class Main {
    /**
     * User friendly date format
     *
     * @param date
     * */
    public static String getDateUserFormat(String date) {
        String formatedDate = "";
        if (date != null) {
            if (date.length() != 0) {
                SimpleDateFormat userFormat = new SimpleDateFormat("d MMM yyyy");
                SimpleDateFormat sqlFormat = new SimpleDateFormat("yyyy-MM-dd");

                try {

                    formatedDate = userFormat.format(sqlFormat.parse(date));
                } catch (ParseException e) {
                    e.printStackTrace();
                }
            }
        }
        return formatedDate;
    }
}