1. 程式人生 > >在schema中datetime 的型別(符合 ISO 8601 格式)如何轉換,如何通過其格式驗證!

在schema中datetime 的型別(符合 ISO 8601 格式)如何轉換,如何通過其格式驗證!

  // Determine the time zone and concatenate the time zone
  // designator
  // onto the formatted date/time string.
  TimeZone tz = isoFormat_.getTimeZone();
  String tzName = tz.getDisplayName();
  if (tzName.equals("Greenwich Mean Time")) {
   dateString = dateString.concat("Z");
  } else {
   // Determine the hour offset. Add an hour if daylight
   // savings
   // is in effect.
   long tzOffsetMS = tz.getRawOffset();
   long tzOffsetHH = tzOffsetMS / MS_IN_HOUR;
   if (tz.inDaylightTime(inputDate)) {
    tzOffsetHH = tzOffsetHH + 1;
   }
   String hourString = String.valueOf(Math.abs(tzOffsetHH));
   if (hourString.length() == 1) {
    hourString = "0" + hourString;
   }