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 java.util.Locale;

public class Main {
    /**
     * Parse the date from server to String for local database
     *
     * @param date_received date received from server
     * @return Date for storing in local database
     */
    public static Date parseDateFromString(String date_received) {
        //2014-06-28 14:56:59
        SimpleDateFormat dateFormat_received = new SimpleDateFormat("yyyy-MM-dd' 'HH:mm:ss", Locale.getDefault());
        Date date = null;
        try {
            date = dateFormat_received.parse(date_received);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return date;
    }
}