The toString() of Date uses the format dow mon dd hh:mm:ss zzz yyyy to return as a String the value of the date, where:
- dowis the day of the week, in your case- Sat(saturday)
- monis the month, the- Feb(February) of its result
- ddis the day of the month represented as two digits, of 01 to 31, in your case day 26
- hhis the time of day, with values of 00 until 23, the 11 of your leaving.
- mmis the representation, also in two digits, of the minute, the 38 of your leaving
- ssis the second, again represented in two digits, of 00 until 61
- zzzis the time zone, the- BRTmay be empty if not available
- yyyyis the year, in four digits, as the 2015
So for the output you need, just use a DateFormat in the pattern you need, in case, dd-MM-yyyy. In this pattern, we will have:
- ddthe day of the month, ranging from 01 to 31
- MMthe month, no longer represented as- Jan,- Feb, etc., but in two digits, of 01 to 12
- yyyybeing the year, in four digits
An example using Calendar would be this:
final DateFormat df = new SimpleDateFormat("dd-MM-yyyy");
final Calendar cal = Calendar.getInstance();
System.out.println(df.format(cal.getTime()));
This will print in the pattern you need.
Another point that is perhaps important to note: since getDate(String) returns a java.sql.Date and she is the subclass of java.util.Date, it is not necessary to configure it in a Calendar, you can do directly, thus:
final DateFormat df = new SimpleDateFormat("dd-MM-yyyy");
final Date date = rs.getDate("dataInicio");
System.out.println(df.format(date));
To display correctly on your dialog, you can use something this way:
final DateFormat df = new SimpleDateFormat("dd-MM-yyyy");
final String dataFormatada = df.format(contato.getDataInicio().getTime());
JOptionPane.showMessageDialog(null, "Data de inicio: " + dataFormatada);
							
							
						 
Thank you very much ;)
– Marcelo T. Cortes