import java.io.*;
import java.lang.*;
import java.util.*;
+import java.text.NumberFormat;
import gnu.regexp.*;
/**
* Statische Hilfsmethoden zur Stringbehandlung
*
- * @version 29.6.99
- * @author RK
+ * @version $Revision: 1.23 $ $Date: 2002/06/28 20:39:37 $
+ * @author $Author: mh $
+ *
+ * $Log: StringUtil.java,v $
+ * Revision 1.23 2002/06/28 20:39:37 mh
+ * added numberformat helper. make webdbDate2readableDate use webdb_create instead. make the order and appearance of it more consistent. cvs macros. and finally code tidying
+ *
+ *
*/
public final class StringUtil {
}
}
+ /**
+ * Formats a number with the specified minimum and maximum number of digits.
+ **/
+ public static synchronized String zeroPaddingNumber(long value, int minDigits,
+ int maxDigits)
+ {
+ NumberFormat numberFormat = NumberFormat.getInstance();
+ numberFormat.setMinimumIntegerDigits(minDigits);
+ numberFormat.setMaximumIntegerDigits(maxDigits);
+ return numberFormat.format(value);
+ }
/**
* Wandelt Datum in einen 8-ziffrigen String um (yyyymmdd)
* wandelt Calendar in dd.mm.yyyy um
*
* @param theDate
- * @return String mit <code>dd.mm.yyyy</code>
+ * @return String mit <code>yyyy.mm.dd</code>
*/
public static final String webdbDate2readableDate (String webdbDate) {
String date = "";
- date += webdbDate.substring(6, 8);
- date += "." + webdbDate.substring(4, 6);
- date += "." + webdbDate.substring(0, 4);
+ date += webdbDate.substring(0, 4);
+ date += "-" + webdbDate.substring(5, 7);
+ date += "-"+webdbDate.substring(8, 10);
return date;
}
return returnDate.toString();
}
- /**
+ /**
* converts string from format: yyyy-mm-dd__hh:mm:ss.dddddd+TZ
* to yyyy-mm-ddThh:mm:ss+TZ:00 (w3 format for Dublin Core)
*/
public static String webdbdateToDCDate(String date) {
StringBuffer returnDate = new StringBuffer();
if (date!=null) {
-
- returnDate.append(date.substring(0,10));
- returnDate.append("T");
- returnDate.append(date.substring(11,19));
- //String tzInfo=date.substring(26,29);
- //if (tzInfo.equals("+00")){
- //UTC gets a special code in w3 dates
- // returnDate.append("Z");
- //}
- //else{
- //need to see what a newfoundland postgres
- //timestamp looks like before making this robust
- // returnDate.append(tzInfo);
- // returnDate.append(":00");
- //}
-
+ returnDate.append(date.substring(0,10));
+ returnDate.append("T");
+ returnDate.append(date.substring(11,19));
+ //String tzInfo=date.substring(26,29);
+ //if (tzInfo.equals("+00")){
+ //UTC gets a special code in w3 dates
+ // returnDate.append("Z");
+ //}
+ //else{
+ //need to see what a newfoundland postgres
+ //timestamp looks like before making this robust
+ // returnDate.append(tzInfo);
+ // returnDate.append(":00");
+ //}
+
}
return returnDate.toString();
}