code: public static GeometryCollection convert(GeometryCollection gc, int dimension) {
          int nb = gc.getNumGeometries();
          final Geometry[] geometries = new Geometry[nb];        
          for (int i = 0; i < nb; i++) {            
              geometries[i]=force(gc.getGeometryN(i),dimension);
          }
          return gf.createGeometryCollection(geometries);        
      }
docs: Force the dimension of the GeometryCollection and update correctly the coordinate
  dimension
  @param gc
  @param dimension
  @return