I am trying to do a SalesForce query from Java, and I want to insert the current date and time into the query. However, I also want to add a wildcard for title, and the percent for the wildcard is being interpreted as a format specifier and giving an error.
String soqlQuery = new String.format("SELECT Id, Title, CreatedDate "
+ "FROM FeedItem "
+ "WHERE title like '%ven%' and createdDate %s ", timeOfLastQuery);
I was able to just use string concatenation to get around the problem, but I would like to know if there is a way to do create a query string that contains a wildcard specifically using formatted strings.
You can escape them with another %
like
String soqlQuery = new String.format("SELECT Id, Title, CreatedDate "
+ "FROM FeedItem "
+ "WHERE title like '%%ven%%' and createdDate %s ", timeOfLastQuery);