title: Print using Java a date and time from a MySql DATETIME field
body: <p>I have a problem printing a date I get from a DATETIME field from my MySQL DB. I am trying to print a field with this DATETIME information: 2013-06-23 17:29:40</p>
  
  <p>The format is YEAR-MONTH-DAY HOURS:MINUTES:SECONDS.</p>
  
  <p><strong>Priting the date I get from my DB result (cal.toString()):</strong>
  java.util.GregorianCalendar[time=1372001380000,areFieldsSet=true,areAllFieldsSet=true,lenient=true,zone=sun.util.calendar.ZoneInfo[id="Europe/Paris",offset=3600000,dstSavings=3600000,useDaylight=true,transitions=184,lastRule=java.util.SimpleTimeZone[id=Europe/Paris,offset=3600000,dstSavings=3600000,useDaylight=true,startYear=0,startMode=2,startMonth=2,startDay=-1,startDayOfWeek=1,startTime=3600000,startTimeMode=2,endMode=2,endMonth=9,endDay=-1,endDayOfWeek=1,endTime=3600000,endTimeMode=2]],firstDayOfWeek=2,minimalDaysInFirstWeek=4,ERA=1,YEAR=2013,MONTH=5,WEEK_OF_YEAR=25,WEEK_OF_MONTH=3,DAY_OF_MONTH=23,DAY_OF_YEAR=174,DAY_OF_WEEK=1,DAY_OF_WEEK_IN_MONTH=4,AM_PM=1,HOUR=5,HOUR_OF_DAY=17,MINUTE=29,SECOND=40,MILLISECOND=0,ZONE_OFFSET=3600000,DST_OFFSET=3600000]</p>
  
  <p>I use Integer.toString to transform int attributes to String.
  However <strong>printing the year</strong> I get this:
  1
  <strong>Printing the month:</strong>
  3
  <strong>Printing the day:</strong>
  5
  <strong>Printing the hour:</strong>
  11
  <strong>Printing the minute:</strong>
  12
  <strong>Printing the seconds:</strong>
  13</p>
  
  <p>If I do this:</p>
  
  <pre><code>String month = Integer.toString(cal.get(Calendar.MONTH) + 1);
  if (month.length() == 1)
    month = "0" + month;
  String day = Integer.toString(cal.get(Calendar.DAY_OF_MONTH));
  if (day.length() == 1)
    day = "0" + day;
  String hour = Integer.toString(cal.get(Calendar.HOUR_OF_DAY));
  if (hour.length() == 1)
    hour = "0" + hour;
  String minute = Integer.toString(cal.get(Calendar.MINUTE));
  if (minute.length() == 1)
    minute = "0" + minute;
  String second = Integer.toString(cal.get(Calendar.SECOND));
  if (second.length() == 1)
    second = "0" + second;
  String date= cal.YEAR + "-" + month + "-" + day + " " + hour + ":" + minute + ":" + second;
  </code></pre>
  
  <p>I got this if I print the <strong>date string</strong>:
  1-06-23 17:29:40</p>
  
  <p>Does anybody know what is happening and how can I print the right date? Thanks in advance.</p>