List of usage examples for java.text SimpleDateFormat parse
public Date parse(String source) throws ParseException
From source file:Main.java
public static Calendar parseTimestamp(String timestamp) throws Exception { SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yyyy HH:mm:ss", Locale.US); Date d = sdf.parse(timestamp); Calendar cal = Calendar.getInstance(); cal.setTime(d);/*from ww w . j a va 2 s. c om*/ return cal; }
From source file:Main.java
public static long stringToTime(String dateString, SimpleDateFormat dateFormat) { try {/*from w w w .j av a 2 s .co m*/ return dateFormat.parse(dateString).getTime(); } catch (ParseException e) { e.printStackTrace(); return 0; } }
From source file:Main.java
public static Calendar parseDateString(String dateString, String pattern) throws ParseException { Calendar c = Calendar.getInstance(); SimpleDateFormat sdf = new SimpleDateFormat(pattern); c.setTime(sdf.parse(dateString));// all done return c;/* ww w. j av a2 s . c om*/ }
From source file:Main.java
public static Date stringToDate(String dateString) throws ParseException { SimpleDateFormat df = new SimpleDateFormat(DATE_FORMAT); return df.parse(dateString); }
From source file:Main.java
@SuppressLint("SimpleDateFormat") public static Date getDateFromString(String format, String dateString) throws ParseException { SimpleDateFormat sdf = new SimpleDateFormat(format); return sdf.parse(dateString); }
From source file:Main.java
public static Date getDateFromString(String date, String format) { try {//from www . ja va 2 s .co m SimpleDateFormat df = new SimpleDateFormat(format); return df.parse(date); } catch (ParseException p) { p.printStackTrace(); } return null; }
From source file:MainClass.java
public static Date makeDate(String dateString) throws Exception { SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy"); return formatter.parse(dateString); }
From source file:Main.java
public static final Date parseDate(String date) throws ParseException { SimpleDateFormat dateParser = new SimpleDateFormat(PARSE_FORMAT); return dateParser.parse(date); }
From source file:Main.java
public static void parse(String d) { if (d != null) { for (String parse : formats) { SimpleDateFormat sdf = new SimpleDateFormat(parse); try { Date date = sdf.parse(d); System.out.println("Printing the value of " + parse); System.out.println(date); } catch (ParseException e) { }//from ww w. java 2 s .co m } } }
From source file:Main.java
public static String getTimeDbFormat(String oldTime) throws Exception { SimpleDateFormat displayFormat = new SimpleDateFormat("HH:mm:ss"); SimpleDateFormat parseFormat = new SimpleDateFormat("hh:mm a"); Date date = parseFormat.parse(oldTime); return displayFormat.format(date); }