@Test public void whenParseDateThenResultTimeStamp() { Timestamp date = pj.parseDate("19 фев 17, 17:37"); assertThat(date.toLocalDateTime().toString(), is("2017-02-19T17:37")); }
public Timestamp parseDate(String date) { Calendar calendar = Calendar.getInstance(); if (date.contains("сегодня")) { calendar.set(Calendar.HOUR_OF_DAY, Integer.parseInt(date.substring(9, 11))); calendar.set(Calendar.MINUTE, Integer.parseInt(date.substring(12, 14))); } else if (date.contains("вчера")) { calendar.add(Calendar.DATE, -1); calendar.set(Calendar.HOUR_OF_DAY, Integer.parseInt(date.substring(7, 9))); calendar.set(Calendar.MINUTE, Integer.parseInt(date.substring(10, 12))); } else { try { calendar.setTime(format.parse(date)); } catch (ParseException e) { LOG.error(e.getMessage(), e); } } return new Timestamp(calendar.getTimeInMillis()); }
ParserJsoup { public Timestamp parseDate(String date) { Calendar calendar = Calendar.getInstance(); if (date.contains("сегодня")) { calendar.set(Calendar.HOUR_OF_DAY, Integer.parseInt(date.substring(9, 11))); calendar.set(Calendar.MINUTE, Integer.parseInt(date.substring(12, 14))); } else if (date.contains("вчера")) { calendar.add(Calendar.DATE, -1); calendar.set(Calendar.HOUR_OF_DAY, Integer.parseInt(date.substring(7, 9))); calendar.set(Calendar.MINUTE, Integer.parseInt(date.substring(10, 12))); } else { try { calendar.setTime(format.parse(date)); } catch (ParseException e) { LOG.error(e.getMessage(), e); } } return new Timestamp(calendar.getTimeInMillis()); } }
ParserJsoup { public Timestamp parseDate(String date) { Calendar calendar = Calendar.getInstance(); if (date.contains("сегодня")) { calendar.set(Calendar.HOUR_OF_DAY, Integer.parseInt(date.substring(9, 11))); calendar.set(Calendar.MINUTE, Integer.parseInt(date.substring(12, 14))); } else if (date.contains("вчера")) { calendar.add(Calendar.DATE, -1); calendar.set(Calendar.HOUR_OF_DAY, Integer.parseInt(date.substring(7, 9))); calendar.set(Calendar.MINUTE, Integer.parseInt(date.substring(10, 12))); } else { try { calendar.setTime(format.parse(date)); } catch (ParseException e) { LOG.error(e.getMessage(), e); } } return new Timestamp(calendar.getTimeInMillis()); }  }
ParserJsoup { public Timestamp parseDate(String date) { Calendar calendar = Calendar.getInstance(); if (date.contains("сегодня")) { calendar.set(Calendar.HOUR_OF_DAY, Integer.parseInt(date.substring(9, 11))); calendar.set(Calendar.MINUTE, Integer.parseInt(date.substring(12, 14))); } else if (date.contains("вчера")) { calendar.add(Calendar.DATE, -1); calendar.set(Calendar.HOUR_OF_DAY, Integer.parseInt(date.substring(7, 9))); calendar.set(Calendar.MINUTE, Integer.parseInt(date.substring(10, 12))); } else { try { calendar.setTime(format.parse(date)); } catch (ParseException e) { LOG.error(e.getMessage(), e); } } return new Timestamp(calendar.getTimeInMillis()); }  void start(DBManager db); String parseTopicId(String line); Timestamp parseDate(String date); }
ParserJsoup { public Timestamp parseDate(String date) { Calendar calendar = Calendar.getInstance(); if (date.contains("сегодня")) { calendar.set(Calendar.HOUR_OF_DAY, Integer.parseInt(date.substring(9, 11))); calendar.set(Calendar.MINUTE, Integer.parseInt(date.substring(12, 14))); } else if (date.contains("вчера")) { calendar.add(Calendar.DATE, -1); calendar.set(Calendar.HOUR_OF_DAY, Integer.parseInt(date.substring(7, 9))); calendar.set(Calendar.MINUTE, Integer.parseInt(date.substring(10, 12))); } else { try { calendar.setTime(format.parse(date)); } catch (ParseException e) { LOG.error(e.getMessage(), e); } } return new Timestamp(calendar.getTimeInMillis()); }  void start(DBManager db); String parseTopicId(String line); Timestamp parseDate(String date);  }