+ Element el = article.getElementsByClass("live-timestamp").first();
+ if (el == null) {
+ el = article.getElementsByAttributeValue(
+ "data-click-id", "timestamp").first();
+ }
+
+ String dateAgo = el.text().trim();
+ int h = 0;
+ if (dateAgo.endsWith("hour ago")) {
+ h = 1;
+ } else if (dateAgo.endsWith("hours ago")) {
+ dateAgo = dateAgo.replace("hours ago", "").trim();
+ h = Integer.parseInt(dateAgo);
+ } else if (dateAgo.endsWith("day ago")) {
+ h = 24;
+ } else if (dateAgo.endsWith("days ago")) {
+ dateAgo = dateAgo.replace("days ago", "").trim();
+ h = Integer.parseInt(dateAgo) * 24;
+ }
+
+ long now = new Date().getTime(); // in ms since 1970
+ now = now / (1000l * 60l * 60l); // in hours
+ long then = now - h; // in hours
+ then = then * (60l * 60l); // in seconds
+
+ return Long.toString(then);