Java Parse Date parseDateTime(String date, String time)

Here you can find the source of parseDateTime(String date, String time)

Description

parse Date Time

License

Open Source License

Parameter

Parameter Description
date a parameter
time a parameter

Declaration

public static long parseDateTime(String date, String time) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.text.ParseException;
import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {

    public static long parseDateTime(String date, String time) {
        long long0 = 0l;
        String maxTime = date + " " + time + ":00:000";
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");
        try {//w w w.j a va2 s  .c o m
            Date day = sdf.parse(maxTime);
            return day.getTime();
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return long0;
    }

    public static String getTime(java.util.Date date) {
        return format(date, "HH:mm:ss");
    }

    public static String format(java.util.Date date, String format) {
        String result = "";
        try {
            if (date != null) {
                java.text.DateFormat df = new java.text.SimpleDateFormat(format);
                result = df.format(date);
            }
        } catch (Exception e) {
        }
        return result;
    }

    public static String format(java.util.Date date) {
        return format(date, "yyyy/MM/dd");
    }
}

Related

  1. parseDateTime(String _date)
  2. parseDateTime(String currDate, String format)
  3. parseDateTime(String d, String t)
  4. parseDateTime(String date)
  5. parseDateTime(String date, String format, String locale, String timeZone)
  6. parseDateTime(String dateTime)
  7. parseDateTime(String dateTimeStr)
  8. parseDateTime(String dateTimeString)
  9. parseDateTime(String dateTimeString)