Mercurial > hg > mpdl-group
view software/eXist/mpdl-modules/src/de/mpg/mpiwg/berlin/mpdl/util/Util.java @ 9:1ec29fdd0db8
neue .lex Dateien f?r Normalisierung / externe Objekte update
author | Josef Willenborg <jwillenborg@mpiwg-berlin.mpg.de> |
---|---|
date | Tue, 22 Feb 2011 16:03:45 +0100 |
parents | 408254cf2f1d |
children |
line wrap: on
line source
package de.mpg.mpiwg.berlin.mpdl.util; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.util.Date; import java.util.Properties; public class Util { public Properties getProperties(String fullFileName) { Properties props = new Properties(); try { File file = new File(fullFileName); FileInputStream in = new FileInputStream(file); props.load(in); } catch (IOException e) { } return props; } public String test(String inputStr) { return "BlaBla"; } public String toYearStr(String inputStr) { String retYearStr = inputStr.trim(); int index = inputStr.indexOf("-"); if (index > 0) { retYearStr = inputStr.substring(0, index); retYearStr = retYearStr.trim(); } try { Integer year = new Integer(retYearStr); if (year < 10000 || year > 2500) retYearStr = null; } catch (NumberFormatException e) { retYearStr = null; } return retYearStr; } public Double getSecondWithMillisecondsBetween(Date begin, Date end) { long beginMS = begin.getTime(); long endMS = end.getTime(); long elapsedSeconds = (endMS - beginMS) / 1000; long elapsedMilliSecondsAfterSeconds1 = (endMS - beginMS) - (elapsedSeconds * 1000); Double seconds = new Double(elapsedSeconds + "." + elapsedMilliSecondsAfterSeconds1); return seconds; } }