Tutorial by Examples

You can add wildcards in string resources and populate them at runtime: Edit strings.xml <string name="my_string">This is %1$s</string> Format string as needed String fun = "fun"; context.getString(R.string.my_string, fun);
For full description of patterns, see SimpleDateFormat reference Date now = new Date(); long timestamp = now.getTime(); SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy", Locale.US); String dateStr = sdf.format(timestamp);
Data types to string formatting Data types like int, float, double, long, boolean can be formatted to string using String.valueOf(). String.valueOf(1); //Output -> "1" String.valueOf(1.0); //Output -> "1.0" String.valueOf(1.2345); //Output -> "1.2345" Stri...

Page 1 of 1