Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
last cleanup bits to serverDate before the release. only safe refactoring (method renaming) changes outside of serverDate.
fuchsid517e96714f3
diff --git a/htroot/AccessTracker_p.java b/htroot/AccessTracker_p.javaindex 073091fa5..f663e7fa5 100644--- a/htroot/AccessTracker_p.java+++ b/htroot/AccessTracker_p.java@@ -99,7 +99,7 @@ public class AccessTracker_p {while (ii.hasNext()) {entry = (Map.Entry) ii.next();prop.putHTML("page_list_" + entCount + "_host", host);- prop.put("page_list_" + entCount + "_date", serverDate.shortSecondTime(new Date(((Long) entry.getKey()).longValue())));+ prop.put("page_list_" + entCount + "_date", serverDate.formatShortSecond(new Date(((Long) entry.getKey()).longValue())));prop.putHTML("page_list_" + entCount + "_path", (String) entry.getValue());entCount++;}@@ -115,7 +115,7 @@ public class AccessTracker_p {while (ii.hasNext()) {entry = (Map.Entry) ii.next();prop.putHTML("page_list_" + entCount + "_host", host);- prop.put("page_list_" + entCount + "_date", serverDate.shortSecondTime(new Date(((Long) entry.getKey()).longValue())));+ prop.put("page_list_" + entCount + "_date", serverDate.formatShortSecond(new Date(((Long) entry.getKey()).longValue())));prop.putHTML("page_list_" + entCount + "_path", (String) entry.getValue());entCount++;}@@ -145,7 +145,7 @@ public class AccessTracker_p {prop.put("page_list_" + entCount + "_dark", ((dark) ? 1 : 0) );dark =! dark;prop.putHTML("page_list_" + entCount + "_host", (String) searchProfile.get("host"));- prop.put("page_list_" + entCount + "_date", serverDate.shortSecondTime(new Date(trackerHandle.longValue())));+ prop.put("page_list_" + entCount + "_date", serverDate.formatShortSecond(new Date(trackerHandle.longValue())));prop.put("page_list_" + entCount + "_timestamp", trackerHandle.longValue());if (page == 2) {// local search@@ -199,7 +199,7 @@ public class AccessTracker_p {Iterator ii = handles.iterator();while (ii.hasNext()) {Long timestamp = (Long) ii.next();- prop.put("page_list_" + entCount + "_dates_" + dateCount + "_date", serverDate.shortSecondTime(new Date(timestamp.longValue())));+ prop.put("page_list_" + entCount + "_dates_" + dateCount + "_date", serverDate.formatShortSecond(new Date(timestamp.longValue())));prop.put("page_list_" + entCount + "_dates_" + dateCount + "_timestamp", timestamp.toString());dateCount++;}diff --git a/htroot/Connections_p.java b/htroot/Connections_p.javaindex d2f07c888..fe9d48fd4 100644--- a/htroot/Connections_p.java+++ b/htroot/Connections_p.java@@ -214,7 +214,7 @@ public final class Connections_p {prop.put("list_" + idx + "_proto", prot);if (sessionTime > 1000*60) {prop.put("list_" + idx + "_ms", "0");- prop.put("list_" + idx + "_ms_duration",serverDate.intervalToString(sessionTime));+ prop.put("list_" + idx + "_ms_duration",serverDate.formatInterval(sessionTime));} else {prop.put("list_" + idx + "_ms", "1");prop.putNum("list_" + idx + "_ms_duration", sessionTime);diff --git a/htroot/IndexControlURLs_p.java b/htroot/IndexControlURLs_p.javaindex f9af2d47d..d9a4a390c 100644--- a/htroot/IndexControlURLs_p.java+++ b/htroot/IndexControlURLs_p.java@@ -63,7 +63,7 @@ public class IndexControlURLs_p {prop.put("lurlexport_urlcount", sb.wordIndex.loadedURL.export_count());} else {prop.put("lurlexport", 1);- prop.put("lurlexport_exportfile", sb.getRootPath() + "/DATA/EXPORT/" + serverDate.shortSecondTime());+ prop.put("lurlexport_exportfile", sb.getRootPath() + "/DATA/EXPORT/" + serverDate.formatShortSecond());prop.put("lurlexportfinished", 0);prop.put("lurlexporterror", 0);diff --git a/htroot/IndexImport_p.java b/htroot/IndexImport_p.javaindex 8973f6bfe..ea3ef74a0 100644--- a/htroot/IndexImport_p.java+++ b/htroot/IndexImport_p.java@@ -181,8 +181,8 @@ public final class IndexImport_p {// other informationprop.putNum("running.jobs_" + i + "_percent", currThread.getProcessingStatusPercent());- prop.put("running.jobs_" + i + "_elapsed", serverDate.intervalToString(currThread.getElapsedTime()));- prop.put("running.jobs_" + i + "_estimated", serverDate.intervalToString(currThread.getEstimatedTime()));+ prop.put("running.jobs_" + i + "_elapsed", serverDate.formatInterval(currThread.getElapsedTime()));+ prop.put("running.jobs_" + i + "_estimated", serverDate.formatInterval(currThread.getEstimatedTime()));prop.putHTML("running.jobs_" + i + "_status", currThread.getStatus().replaceAll("\n", "<br>"));// job number of the importer thread@@ -209,7 +209,7 @@ public final class IndexImport_p {prop.put("finished.jobs_" + i + "_runningStatus", "0");}prop.putNum("finished.jobs_" + i + "_percent", currThread.getProcessingStatusPercent());- prop.put("finished.jobs_" + i + "_elapsed", serverDate.intervalToString(currThread.getElapsedTime()));+ prop.put("finished.jobs_" + i + "_elapsed", serverDate.formatInterval(currThread.getElapsedTime()));prop.putHTML("finished.jobs_" + i + "_status", currThread.getStatus().replaceAll("\n", "<br>"));}prop.put("finished.jobs",finishedJobs.length);diff --git a/htroot/Network.java b/htroot/Network.javaindex 84c1e1629..05d6499f3 100644--- a/htroot/Network.java+++ b/htroot/Network.java@@ -146,7 +146,7 @@ public class Network {myqph = 60d * seed.getQPM();prop.put("table_my-version", seed.get(yacySeed.VERSION, "-"));prop.put("table_my-utc", seed.get(yacySeed.UTC, "-"));- prop.put("table_my-uptime", serverDate.intervalToString(60000 * Long.parseLong(seed.get(yacySeed.UPTIME, ""))));+ prop.put("table_my-uptime", serverDate.formatInterval(60000 * Long.parseLong(seed.get(yacySeed.UPTIME, ""))));prop.putNum("table_my-LCount", LCount);prop.putNum("table_my-ICount", ICount);prop.putNum("table_my-RCount", RCount);@@ -452,7 +452,7 @@ public class Network {prop.putHTML(STR_TABLE_LIST + conCount + "_version", yacyVersion.combined2prettyVersion(seed.get(yacySeed.VERSION, "0.1"), shortname));prop.putNum(STR_TABLE_LIST + conCount + "_lastSeen", /*seed.getLastSeenString() + " " +*/ lastseen);prop.put(STR_TABLE_LIST + conCount + "_utc", seed.get(yacySeed.UTC, "-"));- prop.putHTML(STR_TABLE_LIST + conCount + "_uptime", serverDate.intervalToString(60000 * Long.parseLong(seed.get(yacySeed.UPTIME, "0"))));+ prop.putHTML(STR_TABLE_LIST + conCount + "_uptime", serverDate.formatInterval(60000 * Long.parseLong(seed.get(yacySeed.UPTIME, "0"))));prop.putNum(STR_TABLE_LIST + conCount + "_LCount", seed.getLong(yacySeed.LCOUNT, 0));prop.putNum(STR_TABLE_LIST + conCount + "_ICount", seed.getLong(yacySeed.ICOUNT, 0));prop.putNum(STR_TABLE_LIST + conCount + "_RCount", seed.getLong(yacySeed.RCOUNT, 0));diff --git a/htroot/News.java b/htroot/News.javaindex bbf5b0b9d..6ac5363f3 100644--- a/htroot/News.java+++ b/htroot/News.java@@ -138,10 +138,10 @@ public class News {String category = record.category();prop.put("table_list_" + i + "_id", record.id());prop.putHTML("table_list_" + i + "_ori", (seed == null) ? record.originator() : seed.getName());- prop.put("table_list_" + i + "_cre", serverDate.shortSecondTime(record.created()));+ prop.put("table_list_" + i + "_cre", serverDate.formatShortSecond(record.created()));prop.put("table_list_" + i + "_crerfcdate", httpc.dateString(record.created()));prop.put("table_list_" + i + "_cat", category);- prop.put("table_list_" + i + "_rec", (record.received() == null) ? "-" : serverDate.shortSecondTime(record.received()));+ prop.put("table_list_" + i + "_rec", (record.received() == null) ? "-" : serverDate.formatShortSecond(record.received()));prop.put("table_list_" + i + "_dis", record.distributed());Map attributeMap = record.attributes();diff --git a/htroot/SettingsAck_p.java b/htroot/SettingsAck_p.javaindex bfdaef649..d98adb901 100644--- a/htroot/SettingsAck_p.java+++ b/htroot/SettingsAck_p.java@@ -652,7 +652,7 @@ public class SettingsAck_p {}// everything is ok- prop.put("info_crawler.clientTimeout",(crawlerTimeout==0) ? "0" :serverDate.intervalToString(crawlerTimeout));+ prop.put("info_crawler.clientTimeout",(crawlerTimeout==0) ? "0" :serverDate.formatInterval(crawlerTimeout));prop.put("info_crawler.http.maxFileSize",(maxHttpSize==-1)? "-1":serverMemory.bytesToString(maxHttpSize));prop.put("info_crawler.ftp.maxFileSize", (maxFtpSize==-1) ? "-1":serverMemory.bytesToString(maxFtpSize));prop.put("info", "28");diff --git a/htroot/Status.java b/htroot/Status.javaindex ef5755694..8a5d7621e 100644--- a/htroot/Status.java+++ b/htroot/Status.java@@ -198,7 +198,7 @@ public class Status {} else {final long uptime = 60000 * Long.parseLong(yacyCore.seedDB.mySeed().get(yacySeed.UPTIME, "0"));prop.put("peerStatistics", "1");- prop.put("peerStatistics_uptime", serverDate.intervalToString(uptime));+ prop.put("peerStatistics_uptime", serverDate.formatInterval(uptime));prop.putNum("peerStatistics_pagesperminute", yacyCore.seedDB.mySeed().getPPM());prop.putNum("peerStatistics_queriesperhour", Math.round(6000d * yacyCore.seedDB.mySeed().getQPM()) / 100d);prop.putNum("peerStatistics_links", yacyCore.seedDB.mySeed().getLinkCount());@@ -261,7 +261,7 @@ public class Status {prop.put("seedServer_seedFile", sb.getConfig("seedFilePath", ""));}prop.put("seedServer_lastUpload",- serverDate.intervalToString(System.currentTimeMillis() - sb.yc.lastSeedUpload_timeStamp));+ serverDate.formatInterval(System.currentTimeMillis() - sb.yc.lastSeedUpload_timeStamp));} else {prop.put(SEEDSERVER, "0"); // disabled}diff --git a/htroot/rct_p.java b/htroot/rct_p.javaindex c2c33a2f7..d0e29b557 100644--- a/htroot/rct_p.java+++ b/htroot/rct_p.java@@ -68,7 +68,7 @@ public class rct_p {}Date loaddate;try {- loaddate = serverDate.parseShortSecondTime(item.getPubDate());+ loaddate = serverDate.parseShortSecond(item.getPubDate());} catch (ParseException e) {loaddate = new Date();}diff --git a/htroot/yacy/query.java b/htroot/yacy/query.javaindex 6c0499d75..b25d9e249 100644--- a/htroot/yacy/query.java+++ b/htroot/yacy/query.java@@ -85,7 +85,7 @@ public final class query {final String obj = post.get("object", ""); // keyword for query subjectfinal String env = post.get("env", ""); // argument to query- prop.put("mytime", serverDate.shortSecondTime());+ prop.put("mytime", serverDate.formatShortSecond());// check if we are the right target and requester has correct information about this peerif (yacyCore.seedDB.mySeed() == null || !yacyCore.seedDB.mySeed().hash.equals(youare)) {diff --git a/htroot/yacy/transferURL.java b/htroot/yacy/transferURL.javaindex a15df1f0c..6708b9e8e 100644--- a/htroot/yacy/transferURL.java+++ b/htroot/yacy/transferURL.java@@ -66,7 +66,7 @@ public final class transferURL {public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch env) throws InterruptedException {long start = System.currentTimeMillis();long freshdate = 0;- try {freshdate = serverDate.parseShortDayTime("20061101").getTime();} catch (ParseException e1) {}+ try {freshdate = serverDate.parseShortDay("20061101").getTime();} catch (ParseException e1) {}// return variable that accumulates replacementsfinal plasmaSwitchboard sb = (plasmaSwitchboard) env;diff --git a/htroot/yacy/urls.java b/htroot/yacy/urls.javaindex 089c73222..5a0a08a11 100644--- a/htroot/yacy/urls.java+++ b/htroot/yacy/urls.java@@ -79,7 +79,7 @@ public class urls {prop.putHTML("item_" + c + "_referrer", (referrer == null) ? "" : referrer.toNormalform(true, false));prop.putHTML("item_" + c + "_description", entry.name());prop.put("item_" + c + "_author", "");- prop.put("item_" + c + "_pubDate", serverDate.shortSecondTime(entry.appdate()));+ prop.put("item_" + c + "_pubDate", serverDate.formatShortSecond(entry.appdate()));prop.put("item_" + c + "_guid", entry.url().hash());c++;count--;@@ -109,7 +109,7 @@ public class urls {prop.putHTML("item_" + c + "_referrer", (referrer == null) ? "" : referrer.toNormalform(true, false));prop.putHTML("item_" + c + "_description", comp.title());prop.put("item_" + c + "_author", comp.author());- prop.put("item_" + c + "_pubDate", serverDate.shortSecondTime(entry.moddate()));+ prop.put("item_" + c + "_pubDate", serverDate.formatShortSecond(entry.moddate()));prop.put("item_" + c + "_guid", entry.hash());c++;}diff --git a/source/de/anomic/data/blogBoard.java b/source/de/anomic/data/blogBoard.javaindex 08570d363..a2c15ad96 100644--- a/source/de/anomic/data/blogBoard.java+++ b/source/de/anomic/data/blogBoard.java@@ -123,7 +123,7 @@ public class blogBoard {key = nkey;if (key.length() > keyLength) key = key.substring(0, keyLength);if(date == null) date = new Date();- record.put("date", serverDate.shortSecondTime(date));+ record.put("date", serverDate.formatShortSecond(date));if (subject == null) record.put("subject","");else record.put("subject", kelondroBase64Order.enhancedCoder.encode(subject));if (author == null) record.put("author","");@@ -167,7 +167,7 @@ public class blogBoard {System.out.println("DEBUG - ERROR: date field missing in blogBoard");return new Date();}- return serverDate.parseShortSecondTime(c);+ return serverDate.parseShortSecond(c);} catch (ParseException e) {return new Date();}@@ -177,7 +177,7 @@ public class blogBoard {String c = (String) record.get("date");if (c == null) {System.out.println("DEBUG - ERROR: date field missing in blogBoard");- return serverDate.shortSecondTime();+ return serverDate.formatShortSecond();}return c;}@@ -305,7 +305,7 @@ public class blogBoard {}try {- date = serverDate.parseShortSecondTime(StrDate);+ date = serverDate.parseShortSecond(StrDate);} catch (ParseException e1) {date = new Date();}diff --git a/source/de/anomic/http/httpdFileHandler.java b/source/de/anomic/http/httpdFileHandler.javaindex 0967718d7..65bff76d0 100644--- a/source/de/anomic/http/httpdFileHandler.java+++ b/source/de/anomic/http/httpdFileHandler.java@@ -615,7 +615,7 @@ public final class httpdFileHandler {tp.put(servletProperties.PEER_STAT_VERSION, switchboard.getConfig("version", ""));tp.put(servletProperties.PEER_STAT_UPTIME, ((System.currentTimeMillis() - serverCore.startupTime) / 1000) / 60); // uptime in minutestp.put(servletProperties.PEER_STAT_CLIENTNAME, switchboard.getConfig("peerName", "anomic"));- tp.put(servletProperties.PEER_STAT_MYTIME, serverDate.shortSecondTime());+ tp.put(servletProperties.PEER_STAT_MYTIME, serverDate.formatShortSecond());//System.out.println("respond props: " + ((tp == null) ? "null" : tp.toString())); // debug} catch (InvocationTargetException e) {if (e.getCause() instanceof InterruptedException) {diff --git a/source/de/anomic/index/indexURLEntry.java b/source/de/anomic/index/indexURLEntry.javaindex 359e904ef..e750e7f56 100644--- a/source/de/anomic/index/indexURLEntry.java+++ b/source/de/anomic/index/indexURLEntry.java@@ -212,17 +212,17 @@ public class indexURLEntry {this.entry.setCol(col_hash, url.hash(), null);this.entry.setCol(col_comp, encodeComp(url, descr, author, tags, ETag));try {- encodeDate(col_mod, serverDate.parseShortDayTime(prop.getProperty("mod", "20000101")));+ encodeDate(col_mod, serverDate.parseShortDay(prop.getProperty("mod", "20000101")));} catch (ParseException e) {encodeDate(col_mod, new Date());}try {- encodeDate(col_load, serverDate.parseShortDayTime(prop.getProperty("load", "20000101")));+ encodeDate(col_load, serverDate.parseShortDay(prop.getProperty("load", "20000101")));} catch (ParseException e) {encodeDate(col_load, new Date());}try {- encodeDate(col_fresh, serverDate.parseShortDayTime(prop.getProperty("fresh", "20000101")));+ encodeDate(col_fresh, serverDate.parseShortDay(prop.getProperty("fresh", "20000101")));} catch (ParseException e) {encodeDate(col_fresh, new Date());}diff --git a/source/de/anomic/plasma/crawler/plasmaCrawlQueues.java b/source/de/anomic/plasma/crawler/plasmaCrawlQueues.javaindex 424c38a79..b8ed2c86b 100644--- a/source/de/anomic/plasma/crawler/plasmaCrawlQueues.java+++ b/source/de/anomic/plasma/crawler/plasmaCrawlQueues.java@@ -304,7 +304,7 @@ public class plasmaCrawlQueues {referrer = null;}try {- loaddate = serverDate.parseShortSecondTime(item.getPubDate());+ loaddate = serverDate.parseShortSecond(item.getPubDate());} catch (ParseException e) {loaddate = new Date();}diff --git a/source/de/anomic/plasma/dbImport/plasmaDbImporter.java b/source/de/anomic/plasma/dbImport/plasmaDbImporter.javaindex 6d2913273..74d383566 100644--- a/source/de/anomic/plasma/dbImport/plasmaDbImporter.java+++ b/source/de/anomic/plasma/dbImport/plasmaDbImporter.java@@ -237,8 +237,8 @@ public class plasmaDbImporter extends AbstractImporter implements dbImporter {"[" + this.wordChunkStartHash + " .. " + this.wordChunkEndHash + "] " +this.getProcessingStatusPercent() + "%\n" +"Speed: "+ 500*1000/duration + " word entities/s" +- " | Elapsed time: " + serverDate.intervalToString(getElapsedTime()) +- " | Estimated time: " + serverDate.intervalToString(getEstimatedTime()) + "\n" ++ " | Elapsed time: " + serverDate.formatInterval(getElapsedTime()) ++ " | Estimated time: " + serverDate.formatInterval(getEstimatedTime()) + "\n" +"Home Words = " + homeWordIndex.size() +" | Import Words = " + this.importWordIndex.size());this.wordChunkStart = this.wordChunkEnd;diff --git a/source/de/anomic/server/serverDate.java b/source/de/anomic/server/serverDate.javaindex 8fa699ff2..cb4764e78 100644--- a/source/de/anomic/server/serverDate.java+++ b/source/de/anomic/server/serverDate.java@@ -138,9 +138,7 @@ public final class serverDate {for(int i = 0; i < FORMATS_HTTP.length; i++) {try {- synchronized (FORMATS_HTTP[i]) {- return FORMATS_HTTP[i].parse(s);- }+ return parse(FORMATS_HTTP[i], s);} catch (ParseException e) {// on ParseException try again with next parser}@@ -282,14 +280,6 @@ public final class serverDate {return format(FORMAT_SHORT_DAY, new Date());}- /**- * @see #formatShortDay()- * @param tz a TimeZone the resulting date is aligned to.- */- public static String formatShortDay(TimeZone tz) {- return format(FORMAT_SHORT_DAY, new Date(), tz);- }-/*** @see #formatShortDay()* @param date the Date to transform@@ -299,43 +289,73 @@ public final class serverDate {}/**+ * This should only be used, if you need a short date String that needs to be aligned to+ * a special timezone other than GMT/UTC. Be aware that a receiver won't be able to+ * recreate the original Date without additional timezone information.* @see #formatShortDay()* @param date the Date to transform* @param tz a TimeZone the resulting date String should be aligned to.*/public static String formatShortDay(Date date, TimeZone tz) {- return format(FORMAT_SHORT_DAY, date);+ return format(FORMAT_SHORT_DAY, date, tz);}- public static Date parseShortDayTime(String timeString) throws ParseException {- synchronized (serverDate.FORMAT_SHORT_DAY) {- return serverDate.FORMAT_SHORT_DAY.parse(timeString);- }+ /**+ * Parse a String representation of a Date in short day format assuming the date+ * is aligned to the GMT/UTC timezone. An example for such a date string is "20071218".+ * @see #formatShortDay()+ * @throws ParseException The exception is thrown if an error occured during while parsing+ * the String.+ */+ public static Date parseShortDay(String timeString) throws ParseException {+ return parse(FORMAT_SHORT_DAY, timeString);}- public static String shortSecondTime() {- return shortSecondTime(new Date());+ /**+ * Returns the current date in short second format which is a fixed width (14 chars)+ * String including the date and the time like "20071218233510". The result is in GMT/UTC.+ * @see #formatShortDay()+ */+ public static String formatShortSecond() {+ return formatShortSecond(new Date());}- public static String shortSecondTime(Date date) {- synchronized (serverDate.FORMAT_SHORT_SECOND) {- return serverDate.FORMAT_SHORT_SECOND.format(date);- }+ /**+ * Identical to {@link #formatShortDay(Date)}, but for short second format.+ */+ public static String formatShortSecond(Date date) {+ return format(FORMAT_SHORT_SECOND, date);}- public static Date parseShortSecondTime(String timeString) throws ParseException {- synchronized (serverDate.FORMAT_SHORT_SECOND) {- return serverDate.FORMAT_SHORT_SECOND.parse(timeString);- }+ /**+ * Identical to {@link #formatShortDay(Date, TimeZone)}, but for short second format.+ */+ public static String formatShortSecond(Date date, TimeZone tz) {+ return format(FORMAT_SHORT_SECOND, date, tz);+ }++ //TODO check the following 2 parse methods for correct use (GMT vs. different timezone)+ /**+ * Like {@link #parseShortDay(String)}, but for the "short second" format which is short date+ * plus a 6 digit day time value, like "20071218233510". The String should be in GMT/UTC to+ * get a correct Date.+ */+ public static Date parseShortSecond(String timeString) throws ParseException {+ return parse(FORMAT_SHORT_SECOND, timeString);}- public static Date parseShortSecondTime(String remoteTimeString, String remoteUTCOffset) {+ /**+ * Like {@link #parseShortSecond(String)} using additional timezone information provided in an+ * offset String, like "+0100" for CET.+ */+ public static Date parseShortSecond(String remoteTimeString, String remoteUTCOffset) {+ // FIXME: This method returns an incorrect date, check callers!+ // ex: de.anomic.server.serverDate.parseShortSecond("20070101120000", "+0200").toGMTString()+ // => 1 Jan 2007 13:00:00 GMTif (remoteTimeString == null || remoteTimeString.length() == 0) { return new Date(); }if (remoteUTCOffset == null || remoteUTCOffset.length() == 0) { return new Date(); }try {- synchronized(serverDate.FORMAT_SHORT_SECOND) {- return new Date(serverDate.FORMAT_SHORT_SECOND.parse(remoteTimeString).getTime() - serverDate.UTCDiff() + serverDate.UTCDiff(remoteUTCOffset));- }+ return new Date(parse(FORMAT_SHORT_SECOND, remoteTimeString).getTime() - serverDate.UTCDiff() + serverDate.UTCDiff(remoteUTCOffset));} catch (java.text.ParseException e) {serverLog.logFinest("parseUniversalDate", e.getMessage() + ", remoteTimeString=[" + remoteTimeString + "]");return new Date();@@ -345,9 +365,36 @@ public final class serverDate {}}+/**- * called by all public format...(..., TimeZone) methods+ * Format a time inteval in milliseconds into a String of the form+ * X 'day'['s'] HH':'mm*/+ public static String formatInterval(long millis) {+ try {+ long mins = millis / 60000;++ StringBuffer uptime = new StringBuffer();++ int uptimeDays = (int) (Math.floor(mins/1440));+ int uptimeHours = (int) (Math.floor(mins/60)%24);+ int uptimeMins = (int) mins%60;++ uptime.append(uptimeDays)+ .append(((uptimeDays == 1)?" day ":" days "))+ .append((uptimeHours < 10)?"0":"")+ .append(uptimeHours)+ .append(":")+ .append((uptimeMins < 10)?"0":"")+ .append(uptimeMins);++ return uptime.toString();+ } catch (Exception e) {+ return "unknown";+ }+ }++ /** called by all public format...(..., TimeZone) methods */private static String format(SimpleDateFormat format, Date date, TimeZone tz) {TimeZone bakTZ = format.getTimeZone();String result;@@ -361,19 +408,19 @@ public final class serverDate {return result;}- /**- * called by all public format...(...) methods- */+ /** called by all public format...(...) methods */private static String format(SimpleDateFormat format, Date date) {- String result;-synchronized (format) {- result = format.format(date);+ return format.format(date);}-- return result;}+ /** calles by all public parse...(...) methods */+ private static Date parse(SimpleDateFormat format, String dateString) throws ParseException {+ synchronized (format) {+ return format.parse(dateString);+ }+ }// staticspublic final static long secondMillis = 1000;@@ -583,30 +630,6 @@ public final class serverDate {return new String(result);}- public static String intervalToString(long millis) {- try {- long mins = millis / 60000;-- StringBuffer uptime = new StringBuffer();-- int uptimeDays = (int) (Math.floor(mins/1440));- int uptimeHours = (int) (Math.floor(mins/60)%24);- int uptimeMins = (int) mins%60;-- uptime.append(uptimeDays)- .append(((uptimeDays == 1)?" day ":" days "))- .append((uptimeHours < 10)?"0":"")- .append(uptimeHours)- .append(":")- .append((uptimeMins < 10)?"0":"")- .append(uptimeMins);-- return uptime.toString();- } catch (Exception e) {- return "unknown";- }- }-public static long remainingTime(long start, long due, long minimum) {if (due < 0) return -1;long r = due + start - System.currentTimeMillis();@@ -617,7 +640,7 @@ public final class serverDate {//System.out.println("kelondroDate is (" + new kelondroDate().toString() + ")");System.out.println("offset is " + (UTCDiff()/1000/60/60) + " hours, javaDate is " + new Date() + ", correctedDate is " + new Date(correctedUTCTime()));System.out.println("serverDate : " + new serverDate().toShortString(false));- System.out.println(" javaDate : " + shortSecondTime());+ System.out.println(" javaDate : " + formatShortSecond());System.out.println("serverDate : " + new serverDate().toString());System.out.println(" JavaDate : " + DateFormat.getDateInstance().format(new Date()));System.out.println("serverDate0: " + new serverDate(0).toShortString(false));diff --git a/source/de/anomic/yacy/yacyCore.java b/source/de/anomic/yacy/yacyCore.javaindex 9b9b6c70b..0e65ead65 100644--- a/source/de/anomic/yacy/yacyCore.java+++ b/source/de/anomic/yacy/yacyCore.java@@ -325,14 +325,14 @@ public class yacyCore {if (newSeed.getLastSeenUTC() >= this.seed.getLastSeenUTC()) {log.logFine("publish: recently handshaked " + this.seed.get(yacySeed.PEERTYPE, yacySeed.PEERTYPE_SENIOR) +" peer '" + this.seed.getName() + "' at " + this.seed.getPublicAddress() + " with old LastSeen: '" +- serverDate.shortSecondTime(new Date(newSeed.getLastSeenUTC())) + "'");+ serverDate.formatShortSecond(new Date(newSeed.getLastSeenUTC())) + "'");newSeed.setLastSeenUTC();peerActions.peerArrival(newSeed, true);} else {log.logFine("publish: recently handshaked " + this.seed.get(yacySeed.PEERTYPE, yacySeed.PEERTYPE_SENIOR) +" peer '" + this.seed.getName() + "' at " + this.seed.getPublicAddress() + " with old LastSeen: '" +- serverDate.shortSecondTime(new Date(newSeed.getLastSeenUTC())) + "', this is more recent: '" +- serverDate.shortSecondTime(new Date(this.seed.getLastSeenUTC())) + "'");+ serverDate.formatShortSecond(new Date(newSeed.getLastSeenUTC())) + "', this is more recent: '" ++ serverDate.formatShortSecond(new Date(this.seed.getLastSeenUTC())) + "'");this.seed.setLastSeenUTC();peerActions.peerArrival(this.seed, true);}diff --git a/source/de/anomic/yacy/yacyNetwork.java b/source/de/anomic/yacy/yacyNetwork.javaindex 0a0c7b423..9b93972e5 100644--- a/source/de/anomic/yacy/yacyNetwork.java+++ b/source/de/anomic/yacy/yacyNetwork.java@@ -79,7 +79,7 @@ public class yacyNetwork {if (targetHash != null) post.put("youare", targetHash);// time information for synchronization- post.put("mytime", serverDate.shortSecondTime(new Date()));+ post.put("mytime", serverDate.formatShortSecond(new Date()));post.put("myUTC", System.currentTimeMillis());// network identificationdiff --git a/source/de/anomic/yacy/yacyNewsDB.java b/source/de/anomic/yacy/yacyNewsDB.javaindex 658990f9b..acfd43951 100644--- a/source/de/anomic/yacy/yacyNewsDB.java+++ b/source/de/anomic/yacy/yacyNewsDB.java@@ -142,7 +142,7 @@ public class yacyNewsDB {return yacyNewsRecord.newRecord(b.getColString(0, null),b.getColString(1, "UTF-8"),- (b.empty(2)) ? null : serverDate.parseShortSecondTime(b.getColString(2, null), serverDate.UTCDiffString()),+ (b.empty(2)) ? null : serverDate.parseShortSecond(b.getColString(2, null), serverDate.UTCDiffString()),(int) b.getColLong(3),serverCodings.string2map(b.getColString(4, "UTF-8"), ","));@@ -156,7 +156,7 @@ public class yacyNewsDB {kelondroRow.Entry entry = this.news.row().newEntry();entry.setCol(0, r.id().getBytes());entry.setCol(1, r.category().getBytes("UTF-8"));- entry.setCol(2, (r.received() == null) ? null : serverDate.shortSecondTime(r.received()).getBytes());+ entry.setCol(2, (r.received() == null) ? null : serverDate.formatShortSecond(r.received()).getBytes());entry.setCol(3, kelondroBase64Order.enhancedCoder.encodeLong(r.distributed(), 2).getBytes());entry.setCol(4, attributes.getBytes("UTF-8"));return entry;diff --git a/source/de/anomic/yacy/yacyNewsQueue.java b/source/de/anomic/yacy/yacyNewsQueue.javaindex e878869b1..b9f2976eb 100644--- a/source/de/anomic/yacy/yacyNewsQueue.java+++ b/source/de/anomic/yacy/yacyNewsQueue.java@@ -161,7 +161,7 @@ public class yacyNewsQueue {}kelondroRow.Entry b = queueStack.row().newEntry(new byte[][]{r.id().getBytes(),- serverDate.shortSecondTime(new Date()).getBytes()});+ serverDate.formatShortSecond(new Date()).getBytes()});return b;}diff --git a/source/de/anomic/yacy/yacyNewsRecord.java b/source/de/anomic/yacy/yacyNewsRecord.javaindex 23c572ccb..e5b68bd89 100644--- a/source/de/anomic/yacy/yacyNewsRecord.java+++ b/source/de/anomic/yacy/yacyNewsRecord.java@@ -112,8 +112,8 @@ public class yacyNewsRecord {if (attributes.toString().length() > attributesMaxLength) throw new IllegalArgumentException("attributes length (" + attributes.toString().length() + ") exceeds maximum (" + attributesMaxLength + ")");this.category = (attributes.containsKey("cat")) ? (String) attributes.get("cat") : "";if (category.length() > categoryStringLength) throw new IllegalArgumentException("category length (" + category.length() + ") exceeds maximum (" + categoryStringLength + ")");- this.received = (attributes.containsKey("rec")) ? serverDate.parseShortSecondTime((String) attributes.get("rec"), serverDate.UTCDiffString()) : new Date();- this.created = (attributes.containsKey("cre")) ? serverDate.parseShortSecondTime((String) attributes.get("cre"), serverDate.UTCDiffString()) : new Date();+ this.received = (attributes.containsKey("rec")) ? serverDate.parseShortSecond((String) attributes.get("rec"), serverDate.UTCDiffString()) : new Date();+ this.created = (attributes.containsKey("cre")) ? serverDate.parseShortSecond((String) attributes.get("cre"), serverDate.UTCDiffString()) : new Date();this.distributed = (attributes.containsKey("dis")) ? Integer.parseInt((String) attributes.get("dis")) : 0;this.originator = (attributes.containsKey("ori")) ? (String) attributes.get("ori") : "";removeStandards();@@ -136,7 +136,7 @@ public class yacyNewsRecord {if (attributes.toString().length() > attributesMaxLength) throw new IllegalArgumentException("attributes length (" + attributes.toString().length() + ") exceeds maximum (" + attributesMaxLength + ")");this.attributes = attributes;this.received = received;- this.created = serverDate.parseShortSecondTime(id.substring(0, serverDate.PATTERN_SHORT_SECOND.length()), serverDate.UTCDiffString());+ this.created = serverDate.parseShortSecond(id.substring(0, serverDate.PATTERN_SHORT_SECOND.length()), serverDate.UTCDiffString());this.category = category;this.distributed = distributed;this.originator = id.substring(serverDate.PATTERN_SHORT_SECOND.length());@@ -156,8 +156,8 @@ public class yacyNewsRecord {// attention: this has no additional encodingif (this.originator != null) attributes.put("ori", this.originator);if (this.category != null) attributes.put("cat", this.category);- if (this.created != null) attributes.put("cre", serverDate.shortSecondTime(this.created));- if (this.received != null) attributes.put("rec", serverDate.shortSecondTime(this.received));+ if (this.created != null) attributes.put("cre", serverDate.formatShortSecond(this.created));+ if (this.received != null) attributes.put("rec", serverDate.formatShortSecond(this.received));attributes.put("dis", Integer.toString(this.distributed));String theString = attributes.toString();removeStandards();@@ -165,7 +165,7 @@ public class yacyNewsRecord {}public String id() {- return serverDate.shortSecondTime(created) + originator;+ return serverDate.formatShortSecond(created) + originator;}public String originator() {diff --git a/source/de/anomic/yacy/yacyPeerActions.java b/source/de/anomic/yacy/yacyPeerActions.javaindex 0a7cba82d..73e8373d6 100644--- a/source/de/anomic/yacy/yacyPeerActions.java+++ b/source/de/anomic/yacy/yacyPeerActions.java@@ -263,7 +263,7 @@ public class yacyPeerActions {}if (Math.abs(nowUTC0Time - ctimeUTC0) > 60 * 60 * 24 * 1000) {// the new connection is out-of-age, we reject the connection- yacyCore.log.logFine("connect: rejecting out-dated peer '" + seed.getName() + "' from " + seed.getPublicAddress() + "; nowUTC0=" + nowUTC0Time + ", seedUTC0=" + ctimeUTC0 + ", TimeDiff=" + serverDate.intervalToString(Math.abs(nowUTC0Time - ctimeUTC0)));+ yacyCore.log.logFine("connect: rejecting out-dated peer '" + seed.getName() + "' from " + seed.getPublicAddress() + "; nowUTC0=" + nowUTC0Time + ", seedUTC0=" + ctimeUTC0 + ", TimeDiff=" + serverDate.formatInterval(Math.abs(nowUTC0Time - ctimeUTC0)));return false;}diff --git a/source/de/anomic/yacy/yacySeed.java b/source/de/anomic/yacy/yacySeed.javaindex 6bc14649d..3eff1fa55 100644--- a/source/de/anomic/yacy/yacySeed.java+++ b/source/de/anomic/yacy/yacySeed.java@@ -222,7 +222,7 @@ public class yacySeed {this.dna.put(yacySeed.IPTYPE, "∅");// settings that can only be computed by visiting peer- this.dna.put(yacySeed.LASTSEEN, serverDate.shortSecondTime(new Date(System.currentTimeMillis() - serverDate.UTCDiff()))); // for last-seen date+ this.dna.put(yacySeed.LASTSEEN, serverDate.formatShortSecond(new Date(System.currentTimeMillis() - serverDate.UTCDiff()))); // for last-seen datethis.dna.put(yacySeed.USPEED, yacySeed.ZERO); // the computated uplink speed of the peerthis.dna.put(yacySeed.CRWCNT, yacySeed.ZERO);@@ -527,7 +527,7 @@ public class yacySeed {// because java thinks it must apply the UTC offset to the current time,// to create a string that looks like our current time, it adds the local UTC offset to the// time. To create a corrected UTC Date string, we first subtract the local UTC offset.- dna.put(yacySeed.LASTSEEN, serverDate.shortSecondTime(new Date(System.currentTimeMillis() - serverDate.UTCDiff())) );+ dna.put(yacySeed.LASTSEEN, serverDate.formatShortSecond(new Date(System.currentTimeMillis() - serverDate.UTCDiff())) );}/**@@ -535,7 +535,7 @@ public class yacySeed {*/public final long getLastSeenUTC() {try {- final long t = serverDate.parseShortSecondTime(get(yacySeed.LASTSEEN, "20040101000000")).getTime();+ final long t = serverDate.parseShortSecond(get(yacySeed.LASTSEEN, "20040101000000")).getTime();// getTime creates a UTC time number. But in this case java thinks, that the given// time string is a local time, which has a local UTC offset applied.// Therefore java subtracts the local UTC offset, to get a UTC number.@@ -562,7 +562,7 @@ public class yacySeed {/** @return the age of the seed in number of days */public final int getAge() {try {- final long t = serverDate.parseShortSecondTime(get(yacySeed.BDATE, "20040101000000")).getTime();+ final long t = serverDate.parseShortSecond(get(yacySeed.BDATE, "20040101000000")).getTime();return (int) ((System.currentTimeMillis() - (t - getUTCDiff() + serverDate.UTCDiff())) / 1000 / 60 / 60 / 24);} catch (java.text.ParseException e) {return -1;@@ -775,7 +775,7 @@ public class yacySeed {} else {newSeed.dna.put(yacySeed.PORT, Integer.toString(serverCore.getPortNr(sb.getConfig("port", "8080"))));}- newSeed.dna.put(yacySeed.BDATE, serverDate.shortSecondTime(new Date(System.currentTimeMillis() - serverDate.UTCDiff())) );+ newSeed.dna.put(yacySeed.BDATE, serverDate.formatShortSecond(new Date(System.currentTimeMillis() - serverDate.UTCDiff())) );newSeed.dna.put(yacySeed.LASTSEEN, newSeed.dna.get(yacySeed.BDATE)); // just as initial settingnewSeed.dna.put(yacySeed.UTC, serverDate.UTCDiffString());newSeed.dna.put(yacySeed.PEERTYPE, yacySeed.PEERTYPE_VIRGIN);