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 android.support.annotation.NonNull;
import android.support.annotation.Nullable;

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

public class Main {
    @Nullable
    public static Date parseDate(@NonNull String format, @Nullable String date) {
        if (date == null) {
            return null;
        }
        final SimpleDateFormat formatter = new SimpleDateFormat(format, Locale.US);
        formatter.setLenient(false);
        try {
            return formatter.parse(date);
        } catch (ParseException e) {
            return null;
        }
    }
}