List of usage examples for java.text ParseException printStackTrace
public void printStackTrace()
From source file:Main.java
public static Date StringToDate(String dateStr, String formatStr) { DateFormat format = new SimpleDateFormat(formatStr); Date date = null;//w ww. j av a 2 s . co m try { date = format.parse(dateStr); } catch (ParseException e) { e.printStackTrace(); } return date; }
From source file:Main.java
static Date toDate(String _Input) { try {//from ww w. j a v a 2 s . c o m SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); return dateFormat.parse(_Input); } catch (ParseException e) { e.printStackTrace(); } return null; }
From source file:Main.java
public static long getTime(String dateString) { SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); try {// w ww .ja v a 2s . c o m Date date = formatter.parse(dateString); return date.getTime(); } catch (ParseException e) { e.printStackTrace(); } return SystemClock.elapsedRealtime(); }
From source file:Main.java
public static Date getDateFromString(String dateString) { sf.setLenient(true);//from w w w. j ava 2 s . c om Date date = null; try { date = sf.parse(dateString); } catch (ParseException e) { e.printStackTrace(); } return date; }
From source file:Main.java
public static String convert2LocalTime(String time) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); SimpleDateFormat output = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Date d = null;/*from w w w .j av a2 s . c om*/ try { d = sdf.parse(time); } catch (ParseException e) { e.printStackTrace(); } return output.format(d); }
From source file:Main.java
public static long toTimestamp(String date) { java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); java.util.Date temp;//w w w . j a v a2 s. c om try { temp = sdf.parse(date); } catch (ParseException e) { e.printStackTrace(); return -1; } return temp.getTime(); }
From source file:Main.java
public static final Date dateTimeFromStr(String stringDateTime) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Date time = null;/* ww w .j a v a 2s.c o m*/ try { time = sdf.parse(stringDateTime); } catch (ParseException e) { e.printStackTrace(); } return time; }
From source file:Main.java
public static String getFormattedTime(String time) { SimpleDateFormat sdfDate = new SimpleDateFormat("dd-MM-yyyy HH:mm", Locale.ENGLISH); String strDate = null;/* ww w .j av a 2s. c o m*/ try { strDate = String.valueOf(sdfDate.parse(time)); } catch (ParseException e) { e.printStackTrace(); strDate = ""; } return strDate; }
From source file:Main.java
public static void setValueMask(JFormattedTextField textField) { try {/*from ww w . j ava 2 s . c o m*/ MaskFormatter mask = new MaskFormatter("R$ ###.##"); mask.setValidCharacters("0123456789"); mask.setPlaceholderCharacter('0'); textField.setFormatterFactory(new DefaultFormatterFactory(mask)); } catch (ParseException e) { e.printStackTrace(); } }
From source file:Main.java
public static Date StringToDate(String dateStr) { SimpleDateFormat dd = new SimpleDateFormat(fm5); Date date = null;// w ww .j a v a 2s . co m try { date = dd.parse(dateStr); } catch (ParseException e) { e.printStackTrace(); } return date; }