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;
import java.util.Locale;

public class Main {
    public static String findDateWithFormat(String findDate, String format) {
        findDate = findDate.replace(" ", "").replace("-", "").replace(":", "").replace("/", "").replace(".", "");

        Locale currentLocale = new Locale("KOREAN", "KOREA");
        SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmss", currentLocale);
        SimpleDateFormat returnFormatter = new SimpleDateFormat(format, currentLocale);
        String returnValue = "";
        try {
            Date fDate = formatter.parse(findDate);
            returnValue = returnFormatter.format(fDate);
        } catch (ParseException e) {
            e.printStackTrace();
        }

        return returnValue;
    }
}