Here you can find the source of parse(String string)
Parameter | Description |
---|---|
string | data string |
public static Date parse(String string)
//package com.java2s; /**//from w ww . java2s . c o m * Copyright 2017 Institute of Computing Technology, Chinese Academy of Sciences. * Licensed under the terms of the Apache 2.0 license. * Please see LICENSE file in the project root for terms */ import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { /** * Convert a string to date format * @param string data string * @return date */ public static Date parse(String string) { if (string == null) return null; string = string.trim(); if (string.equals("unknown") || string.equals("")) return null; try { if (!"".equals(string)) { SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); return ft.parse(string); } else { System.out.println(string); } } catch (ParseException e) { e.printStackTrace(); } catch (IllegalArgumentException e) { System.out.println("Exception string:" + string); e.printStackTrace(); } return null; } }