{"id":10965,"date":"2015-06-13T05:57:50","date_gmt":"2015-06-13T05:57:50","guid":{"rendered":"http:\/\/www.oracletutoring.ca\/blog\/?p=10965"},"modified":"2015-06-13T05:57:50","modified_gmt":"2015-06-13T05:57:50","slug":"java-programming-the-date-object","status":"publish","type":"post","link":"https:\/\/www.oracletutoring.ca\/blog\/java-programming-the-date-object\/","title":{"rendered":"Java programming:  the Date object"},"content":{"rendered":"<h1>The tutor briefly describes handling the date in Java.<\/h1>\n<p>Being object oriented, Java makes the date an object.  You can create a date object with the line<\/p>\n<p><span style=\"font-family:monospace;color:olive\">Date dat0=new Date();<\/span><\/p>\n<p>The following application shows how to output the date in Java.  One interesting method it contains is getTime(), which produces the number of seconds since 00:00:00 on Jan 1, 1970.<br \/>\n<span style=\"font-family:monospace;color:olive\"><br \/>\nclass DateTest{<br \/>\npublic static void main(String[] args){<br \/>\nDate dat0=new Date();<br \/>\nString datestring=dat0.toString();<span style=\"color:orange\">\/\/converts date to a string<\/span><\/br><br \/>\nSystem.out.println(&#8220;\\nThe date is &#8220;+ datestring +&#8221;\\n&#8221;);<\/br><br \/>\nSystem.out.println(&#8220;The time since Jan 1, 1970, in milliseconds, is &#8220;+dat0.getTime()+&#8221;\\n&#8221;);<\/br><br \/>\n}<span style=\"color:orange\">\/\/end of main()<\/span><br \/>\n}<span style=\"color:orange\">\/\/end of class<\/span><\/p>\n<p>For instructions about compiling and running the file, you might read my article <a href=\"?p=10882\">here<\/a>.<\/p>\n<p>HTH:)<\/p>\n<p>Source:<\/p>\n<p><a href=\"http:\/\/docs.oracle.com\/javase\/7\/docs\/api\/java\/util\/Date.html#Date%28%29\">Java Docs<\/a><\/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 briefly describes handling the date in Java. Being object oriented, Java makes the date an object. You can create a date object with the line Date dat0=new Date(); The following application shows how to output the date in &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"more-link\" href=\"https:\/\/www.oracletutoring.ca\/blog\/java-programming-the-date-object\/\"> <span class=\"screen-reader-text\">Java programming:  the Date object<\/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":[874,873,602],"class_list":["post-10965","post","type-post","status-publish","format-standard","hentry","category-computer-science","tag-handling-the-date-in-java","tag-java-date-object","tag-java-programming"],"_links":{"self":[{"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/posts\/10965","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=10965"}],"version-history":[{"count":26,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/posts\/10965\/revisions"}],"predecessor-version":[{"id":10991,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/posts\/10965\/revisions\/10991"}],"wp:attachment":[{"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/media?parent=10965"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/categories?post=10965"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/tags?post=10965"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}