List of usage examples for java.text ParseException printStackTrace
public void printStackTrace()
From source file:com.github.consiliens.harv.util.Utils.java
/** Converts a list of IRequestLogRecord to a single HAR file. **/ public static void convertRecordsToHAR(final List<IRequestLogRecord> recordsList, final Harv har, final HarvConfig config) { for (final IRequestLogRecord record : recordsList) { final String pageRef = null; Date startedDateTime = null; try {// w ww . j av a2s . c o m startedDateTime = ISO8601DateFormatter .parseDate(ISO8601DateFormatter.format(new Date(record.getTimestamp()))); } catch (final ParseException e) { e.printStackTrace(); } final long time = record.getRequestMilliseconds(); final HarRequest request = createHarRequest(record.getRequest(), config); final HarResponse response = createHarResponse(record.getResponse(), config); final HarCache cache = null; final HarEntryTimings timings = getFakeHarEntryTimings(); final String serverIPAddress = null; final String connection = String.valueOf(record.getRequestId()); final String comment = null; // Har entry is now complete. har.addEntry(new HarEntry(pageRef, startedDateTime, time, request, response, cache, timings, serverIPAddress, connection, comment)); } }
From source file:cn.mypandora.util.MyDateUtils.java
/** * ./*from w w w. ja v a 2s. c om*/ * * @param begin . * @param end ? . * @return */ public static List<String> getDaysListBetweenDates(String begin, String end) { List<String> dateList = new ArrayList<String>(); Date d1; Date d2; try { d1 = DateUtils.parseDate(begin, DATE_FORMAT); d2 = DateUtils.parseDate(end, DATE_FORMAT); if (d1.compareTo(d2) > 0) { return dateList; } do { dateList.add(DateFormatUtils.format(d1, DATE_FORMAT)); d1 = DateUtils.addDays(d1, 1); } while (d1.compareTo(d2) <= 0); } catch (ParseException e) { e.printStackTrace(); } return dateList; }
From source file:cn.mypandora.util.MyDateUtils.java
/** * // w w w. j a v a2s . c o m * * @param begin * @param end * @return */ public static List<String> getMonthsListBetweenDates(String begin, String end) { List<String> dateList = new ArrayList<String>(); Date d1; Date d2; try { d1 = DateUtils.parseDate(begin, DATE_FORMAT); d2 = DateUtils.parseDate(end, DATE_FORMAT); if (d1.compareTo(d2) > 0) { return dateList; } do { dateList.add(DateFormatUtils.format(d1, MONTH_FORMAT)); d1 = DateUtils.addMonths(d1, 1); } while (d1.compareTo(d2) <= 0); } catch (ParseException e) { e.printStackTrace(); } return dateList; }
From source file:DateUtil.java
/** * Convert an Object to a DateTime, without an Exception *//*from ww w.j ava 2s . c o m*/ public static java.util.Date getDateTime(Object value) { try { return toDateTime(value); } catch (ParseException pe) { pe.printStackTrace(); return null; } }
From source file:DateUtil.java
/** * Convert an Object to a Date, without an Exception *//*from www .ja v a2 s .c om*/ public static java.sql.Date getDate(Object value) { try { return toDate(value); } catch (ParseException pe) { pe.printStackTrace(); return null; } }
From source file:DateUtil.java
/** * Convert an Object to a Time, without an Exception *///from ww w . j av a 2 s . c o m public static java.sql.Time getTime(Object value) { try { return toTime(value); } catch (ParseException pe) { pe.printStackTrace(); return null; } }
From source file:DateUtil.java
/** * Convert an Object to a Timestamp, without an Exception *//*from www .j a v a 2s.c om*/ public static java.sql.Timestamp getTimestamp(Object value) { try { return toTimestamp(value); } catch (ParseException pe) { pe.printStackTrace(); return null; } }
From source file:gov.nih.nci.cabig.caaers.service.ProxyWebServiceFacade.java
private static Map<String, String> buildCriteriaMap(String criteria) { Map<String, String> criteriaMap = new HashMap<String, String>(); String since = ""; try {//w w w . j av a2 s .co m since = DateUtils.formatDateForWS(DateUtils.parseDate("01/01/1990")); } catch (ParseException e) { e.printStackTrace(); } criteriaMap.put("createdDate", since); criteriaMap.put("lastUpdatedDate", since); return criteriaMap; }
From source file:com.ushahidi.android.app.util.Util.java
/** * Format date into more readable format. * // w ww . j a v a2s . com * @param date - the date to be formatted. * @return String */ public static String formatDate(String dateFormat, String date, String toFormat) { String formatted = ""; DateFormat formatter = new SimpleDateFormat(dateFormat); try { Date dateStr = formatter.parse(date); formatted = formatter.format(dateStr); Date formatDate = formatter.parse(formatted); formatter = new SimpleDateFormat(toFormat); formatted = formatter.format(formatDate); } catch (ParseException e) { e.printStackTrace(); } return formatted; }
From source file:com.github.consiliens.harv.util.Utils.java
/** * Extracts headers from allHeaders and updates harHeaders and harCookies. * /*from w w w . j a va 2 s. co m*/ * Returns the size of the headers (calculated by summing the length of * each name and value in UTF8 bytes). **/ public static long extractHeadersAndCookies(final Header[] allHeaders, final HarHeaders harHeaders, final HarCookies harCookies) { long headersSize = 0; final CookieDecoder decoder = new CookieDecoder(); final CookieDateFormat format = new CookieDateFormat(); for (final Header header : allHeaders) { final String headerName = header.getName(); final String headerValue = header.getValue(); try { headersSize += headerName.getBytes(UTF8).length + headerValue.getBytes(UTF8).length; } catch (final UnsupportedEncodingException e1) { e1.printStackTrace(); } harHeaders.addHeader(new HarHeader(headerName, headerValue)); if (headerValue != null && headerName.equalsIgnoreCase("Cookie")) { final Set<Cookie> cookies = decoder.decode(headerValue); for (final Cookie cookie : cookies) { Date expires = null; final int maxAge = cookie.getMaxAge(); if (maxAge != -1) { try { // TODO: Is CookieDateFormat formatting maxAge // properly? expires = format.parse(format.format(maxAge)); } catch (final ParseException e) { e.printStackTrace(); } } harCookies.addCookie( new HarCookie(cookie.getName(), cookie.getValue(), cookie.getPath(), cookie.getDomain(), expires, cookie.isHttpOnly(), cookie.isSecure(), cookie.getComment())); } } } return headersSize; }