code: public static Polygon convert(Polygon polygon, int dimension) {
          LinearRing shell = GeometryCoordinateDimension.convert(polygon.getExteriorRing(),dimension);
          int nbOfHoles = polygon.getNumInteriorRing();
          final LinearRing[] holes = new LinearRing[nbOfHoles];
          for (int i = 0; i < nbOfHoles; i++) {
              holes[i] = GeometryCoordinateDimension.convert(polygon.getInteriorRingN(i),dimension);
          }
          return gf.createPolygon(shell, holes);
      }
docs: Force the dimension of the Polygon and update correctly the coordinate
  dimension
  @param polygon
  @param dimension
  @return