code: private static double compute3DPerimeter(Geometry geometry) {
          double sum = 0;
          for (int i = 0; i < geometry.getNumGeometries(); i++) {
              Geometry subGeom = geometry.getGeometryN(i);
              if (subGeom instanceof Polygon) {
                  sum += ST_3DLength.length3D(((Polygon) subGeom).getExteriorRing());
              } 
          }
          return sum;
      }
docs: Compute the 3D perimeter
  @param geometry
  @return