{"id":1842,"date":"2014-07-30T10:47:00","date_gmt":"2014-07-30T15:47:00","guid":{"rendered":"http:\/\/linuxitos.com\/main\/obtener-fecha-del-sistema-y-colocarlo-en-un-jdatechooser-java\/"},"modified":"2014-07-30T10:47:00","modified_gmt":"2014-07-30T15:47:00","slug":"obtener-fecha-del-sistema-y-colocarlo-en-un-jdatechooser-java","status":"publish","type":"post","link":"https:\/\/linuxitos.com\/main\/obtener-fecha-del-sistema-y-colocarlo-en-un-jdatechooser-java\/","title":{"rendered":"Obtener fecha del sistema y colocarlo en un JDateChooser Java"},"content":{"rendered":"<div dir=\"ltr\" style=\"text-align: left;\">\n<div style=\"text-align: justify;\">Recientemente me fue necesario obtener la fecha del sistema para colocarlo en un JDateChooser, con la finalidad de que la fecha no fuera null, ya que eso puede causar excepciones cuando se intente obtener la fecha de un JDateChooser en caso de que no haya fecha seleccionada.<\/div>\n<div style=\"text-align: justify;\">Para agregar el JCalendar a la paleta seguir este tutorial&nbsp;<\/div>\n<div>\n<div style=\"text-align: justify;\">La interfaz que se crea es sencilla, es la siguiente:<\/div>\n<\/div>\n<div style=\"clear: both; text-align: center;\"><\/div>\n<p><a href=\"http:\/\/1.bp.blogspot.com\/-kK9iziUlL8U\/U9kSPbxkbBI\/AAAAAAAAAJU\/_4Ri9-sEn9o\/s1600\/Captura+de+pantalla+de+2014-07-30+10:41:04.png\" style=\"margin-left: 1em; margin-right: 1em;\"><img decoding=\"async\" border=\"0\" src=\"http:\/\/1.bp.blogspot.com\/-kK9iziUlL8U\/U9kSPbxkbBI\/AAAAAAAAAJU\/_4Ri9-sEn9o\/s1600\/Captura+de+pantalla+de+2014-07-30+10:41:04.png\" \/><\/a><br \/>Previo a esto, es necesario agregar un jar llamado jcalendar, tal y como se ve en la imagen de abajo:<\/p>\n<div style=\"clear: both; text-align: center;\"><a href=\"http:\/\/2.bp.blogspot.com\/-UqUnmjFJTh0\/ViWyHtJC3YI\/AAAAAAAABcI\/F9KyvuwgH20\/s1600\/Captura%2Bde%2Bpantalla%2Bde%2B2015-10-19%2B21-47-27.png\" style=\"margin-left: 1em; margin-right: 1em;\"><img loading=\"lazy\" decoding=\"async\" border=\"0\" height=\"220\" src=\"http:\/\/2.bp.blogspot.com\/-UqUnmjFJTh0\/ViWyHtJC3YI\/AAAAAAAABcI\/F9KyvuwgH20\/s400\/Captura%2Bde%2Bpantalla%2Bde%2B2015-10-19%2B21-47-27.png\" width=\"400\" \/><\/a><\/div>\n<div style=\"text-align: justify;\">Es un JFrame que contiene una JLabel y un JDateChooser. Todo lo que hay que hacer es agregar lo siguiente el constructor que trae por el default.<\/div>\n<div><\/div>\n<div>\n<div>public FechasJdate() {<\/div>\n<div>&nbsp; &nbsp; &nbsp; &nbsp; initComponents();<\/div>\n<div>&nbsp; &nbsp; &nbsp; &nbsp; Calendar c2 = new GregorianCalendar();<\/div>\n<div>&nbsp; &nbsp; &nbsp; &nbsp; jDateChooser1.setCalendar(c2);<\/div>\n<div>}<\/div>\n<\/div>\n<div><\/div>\n<div>Ahora a ejecutar el paquete y listo. Cuando inicie el programa autom\u00e1ticamente la fecha del d\u00eda se mostrar\u00e1 en el JDateChooser <\/p>\n<p>El ejemplo lo pueden descargar de aqu\u00ed: <a href=\"https:\/\/mega.nz\/#!DFg0mLRT!AsMvgh4DX3QDklgKRBKL0b-rohPgriekVBTEmaRTenw\"><span data-pseudo-content=\"Enlace de Carpeta\/Fichero\">https:\/\/mega.nz\/#!DFg0mLRT<\/span><span data-pseudo-content=\"Clave de Cifrado\">!AsMvgh4DX3QDklgKRBKL0b-rohPgriekVBTEmaRTenw<\/span><\/a><\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Recientemente me fue necesario obtener la fecha del sistema para colocarlo en un JDateChooser, con la finalidad de que la fecha no fuera null, ya que eso puede causar excepciones cuando se intente obtener la fecha de un JDateChooser en caso de que no haya fecha seleccionada. Para agregar el JCalendar a la paleta seguir [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[745,7,87,1503,446,1502,1504,359],"tags":[],"class_list":["post-1842","post","type-post","status-publish","format-standard","hentry","category-calendar","category-fedora","category-gnome","category-gregoriancalendar","category-java","category-jcalendar","category-jdatechooser","category-netbeans"],"_links":{"self":[{"href":"https:\/\/linuxitos.com\/main\/wp-json\/wp\/v2\/posts\/1842","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxitos.com\/main\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxitos.com\/main\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxitos.com\/main\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxitos.com\/main\/wp-json\/wp\/v2\/comments?post=1842"}],"version-history":[{"count":0,"href":"https:\/\/linuxitos.com\/main\/wp-json\/wp\/v2\/posts\/1842\/revisions"}],"wp:attachment":[{"href":"https:\/\/linuxitos.com\/main\/wp-json\/wp\/v2\/media?parent=1842"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxitos.com\/main\/wp-json\/wp\/v2\/categories?post=1842"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxitos.com\/main\/wp-json\/wp\/v2\/tags?post=1842"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}