code: public static Geometry toGeometry(String wkt, int srid) throws SQLException {
          if(wkt == null) {
              return null;
          }
          try {
              WKTReader wktReaderSRID = new WKTReader(new GeometryFactory(new PrecisionModel(),srid));
              return wktReaderSRID.read(wkt);
          } catch (ParseException ex) {
              throw new SQLException(ex);
          }
      }
docs: Convert well known text parameter into a Geometry
  @param wkt Well known text
  @param srid Geometry SRID
  @return Geometry instance
  @throws SQLException If wkt is invalid