public static void printDayTimeDurationString(byte[] b, int s, int l, PrintStream ps)
      throws HyracksDataException {
    boolean positive = true;
    long milliseconds = AInt64SerializerDeserializer.getLong(b, s + 1);

    // set the negative flag. "||" is necessary in case that months field is not there (so it is 0)
    if (milliseconds < 0) {
      milliseconds *= -1;
      positive = false;
    }

    int millisecond = gCalInstance.getDurationMillisecond(milliseconds);
    int second = gCalInstance.getDurationSecond(milliseconds);
    int minute = gCalInstance.getDurationMinute(milliseconds);
    int hour = gCalInstance.getDurationHour(milliseconds);
    int day = gCalInstance.getDurationDay(milliseconds);

    if (!positive) {
      ps.print("-");
    }
    try {
      ps.print("P");
      if (day != 0) {
        WriteValueTools.writeInt(day, ps);
        ps.print("D");
      }
      if (hour != 0 || minute != 0 || second != 0 || millisecond != 0) {
        ps.print("T");
      }
      if (hour != 0) {
        WriteValueTools.writeInt(hour, ps);
        ps.print("H");
      }
      if (minute != 0) {
        WriteValueTools.writeInt(minute, ps);
        ps.print("M");
      }
      if (second != 0 || millisecond != 0) {
        WriteValueTools.writeInt(second, ps);
      }
      if (millisecond > 0) {
        ps.print(".");
        WriteValueTools.writeInt(millisecond, ps);
      }
      if (second != 0 || millisecond != 0) {
        ps.print("S");
      }
    } catch (IOException e) {
      throw new HyracksDataException(e);
    }
  }