Java Parse Time parseTime(String time)

Here you can find the source of parseTime(String time)

Description

parse Time

License

Open Source License

Declaration

public static Date parseTime(String time) 

Method Source Code


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

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

public class Main {
    public static Date parseTime(String time) {
        SimpleDateFormat dateFormatter = new SimpleDateFormat("dd-MM-yyyy h.mm a");
        Date temp = dateFormatter.parse(time, new ParsePosition(0));
        if (temp == null) {
            dateFormatter = new SimpleDateFormat("dd-MM-yyyy");
            temp = dateFormatter.parse(time, new ParsePosition(0));
            return temp;
        }/*from w w w  . jav a  2 s .c om*/
        return temp;
    }
}

Related

  1. parseTime(String sTime)
  2. parseTime(String str)
  3. parseTime(String str)
  4. parseTime(String t)
  5. parseTime(String text)
  6. parseTime(String time)
  7. parseTime(String time, String formatStrBefore, String formatStrAfter)
  8. parseTime(String timestring)
  9. parseTime(String timeString, TimeZone timeZone)