Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

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

import android.text.TextUtils;

public class Main {

    public static long parseDateTime(String dateTime) {
        if (TextUtils.isEmpty(dateTime)) {
            return 0;
        }

        long time = 0;
        try {
            Date date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(dateTime);
            if (null != date) {
                time = date.getTime();
            }
        } catch (ParseException e) {
            e.printStackTrace();
        }

        return time;
    }
}