Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

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

import java.util.TimeZone;

public class Main {
    public static Date convertStrToDate(String dateStr) {
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");
        dateFormat.setTimeZone(TimeZone.getTimeZone("GMT+0000"));
        Date date = null;
        try {
            date = dateFormat.parse(dateStr);
        } catch (Exception e) {
            date = null;
        }
        return date;
    }
}