public static Duration castToDuration(String s) {
   if (s == null) throw new java.lang.NullPointerException();
   if (s.length() == 0) throw new IllegalArgumentException("Cast to Duration failed.");
   return Duration.parse(s);
 }
 public static String castToString(Duration dur) {
   return dur.toString();
 }