{"id":9359,"date":"2015-03-29T17:31:06","date_gmt":"2015-03-29T17:31:06","guid":{"rendered":"http:\/\/www.oracletutoring.ca\/blog\/?p=9359"},"modified":"2015-03-29T17:36:19","modified_gmt":"2015-03-29T17:36:19","slug":"java-decimal-formatting-continued","status":"publish","type":"post","link":"https:\/\/www.oracletutoring.ca\/blog\/java-decimal-formatting-continued\/","title":{"rendered":"Java:  decimal formatting, continued"},"content":{"rendered":"<br \/>\n<h1>The tutor continues with the potentially tricky topic of Java decimal formatting.<\/h1>\n<p>&nbsp;<br \/>\nWith <a href=\"?p=9296\">yesterday&#8217;s post<\/a> I broke the ice about Java DecimalFormat with a short demonstration program.  Now, some key points of explanation:<\/p>\n<ol>\n<li>The format descriptor string &#8220;#,###.00&#8221; means that two decimal places will always be shown, even if they are zeros.  However, the number <span style=\"font-family:monospace\">0.79<\/span> will display as <span style=\"font-family:monospace\">.79<\/span> (no zero in front of the decimal point). A &#8220;#&#8221; means that the place will not be shown if it is a leading or trailing zero, whereas a &#8220;0&#8221; means the place will be shown, with a zero if it has no other value.  Therefore, the number 2, formatted as &#8220;#0,000.00&#8221;, will be rendered as 0,002.00 by DecimalFormat.<\/li>\n<p><\/p>\n<li>Notice that the output of DecimalFormat is a string (that <em>looks like a number<\/em>).<\/li>\n<p><\/p>\n<li>The Scanner is not intrinsically connected to DecimalFormat; it is used in the program to read the numbers from the command line.\n<\/li>\n<\/ol>\n<p>While this probably covers the program from yesterday, there is still more to say about Java&#8217;s DecimalFormat.  Not surprisingly, I&#8217;ll be continuing about it in future posts:)<\/p>\n<p>Jack of <a href=\"https:\/\/www.oracletutoring.ca\">Oracle Tutoring by Jack and Diane,<\/a> Campbell River, BC.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The tutor continues with the potentially tricky topic of Java decimal formatting. &nbsp; With yesterday&#8217;s post I broke the ice about Java DecimalFormat with a short demonstration program. Now, some key points of explanation: The format descriptor string &#8220;#,###.00&#8221; means &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"more-link\" href=\"https:\/\/www.oracletutoring.ca\/blog\/java-decimal-formatting-continued\/\"> <span class=\"screen-reader-text\">Java:  decimal formatting, continued<\/span> Read More &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[105],"tags":[649,648,650,642,602],"class_list":["post-9359","post","type-post","status-publish","format-standard","hentry","category-computer-science","tag-difference-between-hashtags-and-zeros-java-decimalformat","tag-difference-between-number-signs-and-zeros-in-java-decimalformat","tag-formatting-decimals-java","tag-java-decimalformat","tag-java-programming"],"_links":{"self":[{"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/posts\/9359","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/comments?post=9359"}],"version-history":[{"count":22,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/posts\/9359\/revisions"}],"predecessor-version":[{"id":9381,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/posts\/9359\/revisions\/9381"}],"wp:attachment":[{"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/media?parent=9359"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/categories?post=9359"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/tags?post=9359"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}