code: public static Geometry force(Geometry geom, int dimension) {
          if (geom instanceof Point) {
              return gf.createPoint(convertSequence(geom.getCoordinates(),dimension));
          } else if (geom instanceof LineString) {
              return gf.createLineString(convertSequence(geom.getCoordinates(),dimension));
          } else if (geom instanceof Polygon) {
              return GeometryCoordinateDimension.convert((Polygon) geom,dimension);
          } else if (geom instanceof MultiPoint) {
              return gf.createMultiPoint(convertSequence(geom.getCoordinates(),dimension));
          } else if (geom instanceof MultiLineString) {
              return GeometryCoordinateDimension.convert((MultiLineString) geom,dimension);
          } else if (geom instanceof MultiPolygon) {
              return GeometryCoordinateDimension.convert((MultiPolygon) geom,dimension);
          } else if (geom instanceof GeometryCollection) {
              return GeometryCoordinateDimension.convert((GeometryCollection)geom,dimension);
          }
          return geom;
      }
docs: Force the dimension of the geometry and update correctly the coordinate
  dimension
  @param geom the input geometry
  @param dimension supported dimension is 2, 3
  if the dimension is set to 3 the z measure are set to 0
  @return