Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

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

public class Main {
    public static String dateFormatter(String date) {
        // SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
        SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
        SimpleDateFormat sdf2 = new SimpleDateFormat("dd.MM.yyyy", new Locale("tr", "TR"));
        Date d;
        String formatdate = null;
        try {
            d = sdf.parse(date);
            formatdate = sdf2.format(d);
        } catch (ParseException ex) {
            return date;
        }
        return formatdate;
    }
}