editor should support new config ... first steps

This commit is contained in:
2016-09-01 22:05:31 +02:00
committed by Andreas Billmann
parent 6f635f5e75
commit 04a54da798
8 changed files with 109 additions and 132 deletions

View File

@@ -0,0 +1,43 @@
package ninja.javafx.smartcsv.validation;
/**
* @author abi
*/
public class ValidationFormatHelper {
public static String dateFormat(String format, String defaultFormat) {
if (format != null && !format.trim().isEmpty()) {
format = format.trim();
if (format.startsWith("fmt:")) {
format = format.substring(4);
format = format.replace("%Y", "yyyy");
format = format.replace("%y", "yy");
format = format.replace("%m", "MM");
format = format.replace("%d", "dd");
format = format.replace("%a", "E");
format = format.replace("%A", "EEEE");
format = format.replace("%w", "F");
format = format.replace("%b", "MMM");
format = format.replace("%B", "MMMMM");
format = format.replace("%H", "HH");
format = format.replace("%I", "hh");
format = format.replace("%p", "a");
format = format.replace("%M", "mm");
format = format.replace("%S", "ss");
format = format.replace("%z", "Z");
format = format.replace("%Z", "z");
format = format.replace("%j", "DDD");
format = format.replace("%U", "ww");
return format;
}
}
return defaultFormat;
}
public static Integer doubleToInteger(Double value) {
if (value == null) return null;
return (int)Math.round(value);
}
}