{"id":2635,"date":"2015-09-18T01:59:38","date_gmt":"2015-09-18T01:59:38","guid":{"rendered":"http:\/\/www.garysieling.com\/blog\/?p=2635"},"modified":"2015-09-18T01:59:38","modified_gmt":"2015-09-18T01:59:38","slug":"scala-equivalent-for-java-string-format","status":"publish","type":"post","link":"https:\/\/www.garysieling.com\/blog\/scala-equivalent-for-java-string-format\/","title":{"rendered":"Scala equivalent for java.String.format"},"content":{"rendered":"<p>A nice, clean substitute for String.format is string interpolation (which will call toString on your values)<\/p>\n<p>An example is shown here:<\/p>\n<pre lang=\"scala\">\nval t = Calendar.getInstance.getTime\nvar num = 7\nval dec = 3.14\nvar text = \"hello word\"\n\ns\"\"\"Test 1: $t\"\"\"\ns\"\"\"Test 2: $num $dec $text\"\"\"\n<\/pre>\n<p>Which returns:<\/p>\n<pre>\nres21: String = Test 1: Thu Sep 17 21:57:02 EDT 2015\nres22: String = Test 2: 7 3.14 hello world\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>A nice, clean substitute for String.format is string interpolation (which will call toString on your values) An example is shown here: val t = Calendar.getInstance.getTime var num = 7 val dec = 3.14 var text = &#8220;hello word&#8221; s&#8221;&#8221;&#8221;Test 1: $t&#8221;&#8221;&#8221; s&#8221;&#8221;&#8221;Test 2: $num $dec $text&#8221;&#8221;&#8221; Which returns: res21: String = Test 1: Thu Sep &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.garysieling.com\/blog\/scala-equivalent-for-java-string-format\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Scala equivalent for java.String.format&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[4],"tags":[480,488],"aioseo_notices":[],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/posts\/2635"}],"collection":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/comments?post=2635"}],"version-history":[{"count":0,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/posts\/2635\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/media?parent=2635"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/categories?post=2635"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/tags?post=2635"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}