Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Main {

    public static String getTimeFormatNO1(String time) {
        DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        DateFormat wantdf = new SimpleDateFormat("yyyy-MM-dd");
        try {
            Date current = new Date();
            Date tiemBefore = df.parse(time.substring(0, 19).replace("T", " "));
            String str = wantdf.format(tiemBefore);
            return str;
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return "null";
    }
}