I have the following string in my resources:
<string name="days_ago">%1$s days ago</string>
I’m using it like so in my list adapter:
Long daysSincePost = hoursSincePost / 24;
String display = activity.getString(R.string.days_ago);
return String.format(display, Long.toString(daysSincePost));
I’ve verified that Long.toString() returns the correct value that I want to display.
The problem is that the value of daysSincePost never appears in my list view! Instead, I get “days ago“.
Am I using String.format() incorrectly?
I’ve tried using “%1$d days ago” and using the Long value directly, with no change.
I think you want this:
Long.toString(daysSincePost)has an index of ‘0’ instead of ‘1’.