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 android.text.TextUtils;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Main {

    public static String getConverDateString(String date, String fromFormat, String toFormat) {
        if (TextUtils.isEmpty(date))
            return "";
        SimpleDateFormat sdf = new SimpleDateFormat();
        sdf.applyPattern(fromFormat);
        Date d = null;
        try {
            d = sdf.parse(date);
        } catch (ParseException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        sdf.applyPattern(toFormat);
        return sdf.format(d);
    }
}