Java Code Examples for java.text.ParseException#printStackTrace()
The following examples show how to use
java.text.ParseException#printStackTrace() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TimePopupWindow.java From xmpp with Apache License 2.0 | 6 votes |
@Override public void onClick(View v) { String tag = (String) v.getTag(); if (tag.equals(TAG_CANCEL)) { dismiss(); return; } else { if (timeSelectListener != null) { try { Date date = WheelTime.dateFormat.parse(wheelTime.getTime()); timeSelectListener.onTimeSelect(date); } catch (ParseException e) { e.printStackTrace(); } } dismiss(); return; } }
Example 2
Source File: Transaction.java From OpenSZZ-Cloud-Native with GNU General Public License v3.0 | 6 votes |
public Transaction( String hashId, String timestamp, String author, String comment, List<FileInfo> filesAffected) { this.hashId = hashId; Date dateTemp = null; timestamp = timestamp.replace("T", ""); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-ddHH:mm:ssXXX"); try { dateTemp = sdf.parse(timestamp); } catch (ParseException e) { dateTemp = null; e.printStackTrace(); } this.timestamp = dateTemp; this.author = author; this.comment = comment.toLowerCase(); this.filesAffected = filesAffected; }
Example 3
Source File: UserInfoEditActivity.java From WeCenterMobile-Android with GNU General Public License v2.0 | 6 votes |
@Override public void onDateSet(DatePicker view, int year, int month, int day) { // Do something with the date chosen by the user tv_birthday_info.setText(Integer.toString(year) + "-" + Integer.toString((month + 1)) + "-" + Integer.toString(day)); String dateString = Integer.toString(year) + "-" + Integer.toString((month + 1)) + "-" + Integer.toString(day) + " " + "12:00:00"; SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); try { Date date = sdf.parse(dateString); birthday = Long.toString(date.getTime() / 1000); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
Example 4
Source File: DateUtils.java From cms with Apache License 2.0 | 6 votes |
public static long dateDifferent(String before, String after, String pattern) { SimpleDateFormat format = new SimpleDateFormat(pattern); try { Date dateStart = format.parse(before); Date dateStop = format.parse(after); long between = (dateStart.getTime() - dateStop.getTime()) / 1000;// 除以1000是为了转换成秒 return between; } catch (ParseException e) { e.printStackTrace(); // throw new Exception("计算时间差失败!"); } return 0; }
Example 5
Source File: GridCellAdapter.java From JKCalendar with Apache License 2.0 | 6 votes |
@Override public void onClick(View view) { SimpleDateFormat df2 = new SimpleDateFormat("dd-MM-yyy"); Calendar calendarData = Calendar.getInstance(); try { calendarData.setTime(df2.parse((String) view.getTag())); } catch (ParseException e) { e.printStackTrace(); } // Calendar calendarData = (Calendar) view.getTag(); if(iEventDateClick!=null){ iEventDateClick.onClick(calendarData); } }
Example 6
Source File: Helper.java From faveo-helpdesk-android-app with Open Software License 3.0 | 6 votes |
/** * UTC time conversion to local time returns String Date. * @param dateToParse * @return */ public static String parseDate(String dateToParse) { try { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); sdf.setTimeZone(TimeZone.getTimeZone("UTC")); Date dAte = sdf.parse(dateToParse); SimpleDateFormat output = new SimpleDateFormat("d MMM yyyy HH:mm"); output.setTimeZone(TimeZone.getDefault()); String formattedTime = output.format(dAte); SimpleDateFormat day = new SimpleDateFormat("dd"); String formattedDay = day.format(dAte) + Helper.getDayOfMonthSuffix(Integer.parseInt(day.format(dAte))); formattedTime = formattedTime.replaceFirst(formattedTime.substring(0, formattedTime.indexOf(" ")), formattedDay); sdf.parse(dateToParse); return formattedTime; } catch (ParseException e) { e.printStackTrace(); return dateToParse; } }
Example 7
Source File: Helper.java From potato-webmvc with MIT License | 5 votes |
@SuppressWarnings("unchecked") @Override public <T> T convert(Class<T> type, Object value) { Date date = null; DateFormat dateFormat = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss"); try { date = dateFormat.parse((String) value); } catch (ParseException e) { e.printStackTrace(); } return (T) date; }
Example 8
Source File: ThrowsDemo.java From Java with Artistic License 2.0 | 5 votes |
public static void main(String[] args) { // show(); try { show2(); } catch (ParseException e) { e.printStackTrace(); } }
Example 9
Source File: ZYDateUtils.java From Viewer with Apache License 2.0 | 5 votes |
/** * 相同日期不同格式之间转换 * @param date 当前格式的日期字符串 * @param originFormater 原格式 * @param destFormater 目标格式 * @return 目标格式的日期字符串 */ public static String dateString2dateString(String date,String originFormater,String destFormater) { if (date == null || "".equals(date)) return ""; SimpleDateFormat formater = new SimpleDateFormat(); try { formater.applyPattern(originFormater); Date time = formater.parse(date); return date2String(destFormater, time); } catch (ParseException e) { e.printStackTrace(); } return ""; }
Example 10
Source File: DateUtils.java From jeecg-cloud with Apache License 2.0 | 5 votes |
/** * 字符串转换成日期 * * @param str * @param sdf * @return */ public static Date str2Date(String str, SimpleDateFormat sdf) { if (null == str || "".equals(str)) { return null; } Date date = null; try { date = sdf.parse(str); return date; } catch (ParseException e) { e.printStackTrace(); } return null; }
Example 11
Source File: AstroUtil.java From Astrosoft with GNU General Public License v2.0 | 5 votes |
public static Date parseDateTime(String dateStr){ try { return dateTimeFormat.parse(dateStr); } catch (ParseException e) { e.printStackTrace(); return null; } }
Example 12
Source File: DateUtils.java From mykit-db-sync with Apache License 2.0 | 5 votes |
public static long getLongTypetime(String times) { DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm"); try { return df.parse(times).getTime(); } catch (ParseException e) { e.printStackTrace(); } return 0L; }
Example 13
Source File: DateUtils.java From zheshiyigeniubidexiangmu with MIT License | 5 votes |
/** * 字符串到日期 * @param str_date 只能格式化yyyy-MM-dd * @return */ public static Date strToDate(String str_date) { SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); Date date = null; try { date = simpleDateFormat.parse(str_date); } catch (ParseException e) { e.printStackTrace(); } return date; }
Example 14
Source File: DateUtils.java From SuperBoot with MIT License | 5 votes |
/** * 取得当前日期所在周的前一周最后一天 * * @param date * @return */ public static String getLastDayOfLastWeek(String date) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); Calendar calendar = Calendar.getInstance(); calendar.setFirstDayOfWeek(Calendar.MONDAY); try { calendar.setTime(sdf.parse(date)); } catch (ParseException e) { e.printStackTrace(); } return getLastDayOfWeek(calendar.get(Calendar.YEAR), calendar.get(Calendar.WEEK_OF_YEAR) - 1); }
Example 15
Source File: JobUtil.java From spring-boot-quartz-demo with MIT License | 5 votes |
/** * Create cron trigger. * * @param triggerName Trigger name. * @param startTime Trigger start time. * @param cronExpression Cron expression. * @param misFireInstruction Misfire instruction (what to do in case of misfire happens). * * @return Trigger */ protected static Trigger createCronTrigger(String triggerName, Date startTime, String cronExpression, int misFireInstruction){ PersistableCronTriggerFactoryBean factoryBean = new PersistableCronTriggerFactoryBean(); factoryBean.setName(triggerName); factoryBean.setStartTime(startTime); factoryBean.setCronExpression(cronExpression); factoryBean.setMisfireInstruction(misFireInstruction); try { factoryBean.afterPropertiesSet(); } catch (ParseException e) { e.printStackTrace(); } return factoryBean.getObject(); }
Example 16
Source File: TimeUtil.java From NIM_Android_UIKit with MIT License | 5 votes |
public static Date getDateFromFormatString(String formatDate) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); try { return sdf.parse(formatDate); } catch (ParseException e) { e.printStackTrace(); } return null; }
Example 17
Source File: DateAdapter.java From kripton with Apache License 2.0 | 5 votes |
@Override public Date toJava(String dataValue) { if (dataValue==null) return null; Date date=null; try { date = formatter.parse(dataValue); } catch (ParseException e) { e.printStackTrace(); } return date; }
Example 18
Source File: CalendarHelper.java From guarda-android-wallets with GNU General Public License v3.0 | 5 votes |
public static long jodaTimeToMilliseconds(String dateStr) { SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss", Locale.getDefault()); Date date = null; try { date = format.parse(dateStr); } catch (ParseException e) { e.printStackTrace(); } return date.getTime(); }
Example 19
Source File: DateUtil.java From imsdk-android with MIT License | 5 votes |
/** * 将时间字符串转换为Date类型 * @param dateStr * @return Date */ public static Date toDate(String dateStr) { Date date = null; SimpleDateFormat formater = new SimpleDateFormat(); formater.applyPattern("yyyy-MM-dd"); try { date = formater.parse(dateStr); } catch (ParseException e) { e.printStackTrace(); } return date; }
Example 20
Source File: DateAdapter.java From kripton with Apache License 2.0 | 5 votes |
@Override public Date toJava(String dataValue) { if (dataValue==null) return null; Date date=null; try { date = formatter.parse(dataValue); } catch (ParseException e) { e.printStackTrace(); } return date; }