Using Java String.format() how do I format a string to result in “Time – userId” (ie. 3:02 pm – joe user).
I have worked several iterations, and I think it is the space between the minutes and the am/pm that is throwing me off. My last iteration is
String.format("%1$tl:%1$tM %1$tp - %2s", new Date(), "joe user");
I am about to punt and use a SimpleDateFormat, but thought I would ask here first.
You need
%2$sto get the second argument, as shown below:prints: