time problem
i am getting the time using java's Calendar
i have a problem on the minute part though
when the time is 9:04, it displays 9:4 instead and so on. please help on how i can display the proper minute? this is my code.
publicint getMinute()
{
return calendar.get(Calendar.MINUTE);
}
thanks
[489 byte] By [
shuinia] at [2007-11-26 18:14:16]

It appears that you're combing strings without doing the necessary formatting brfore combining them.If that's the case, you'll need to format the minutes value as a two-character string first.Or use Simple Date Format to format the time - this is the correct way to do it.
well, this is what i have so far
public int getHour()
{
return calendar.get(Calendar.HOUR_OF_DAY);
}
public int getMinute()
{
return calendar.get(Calendar.MINUTE);
}
public String getTime()
{
return getHour() + ":" + getMinute();
}
so when i do the getTime, it gives me 9:1, 9:2, instead of 9:01 and 9:02
public int getHour()
{
return calendar.get(Calendar.HOUR_OF_DAY);
}
public int getMinute()
{
return calendar.get(Calendar.MINUTE);
}
public String getTime()
{
return getHour() + ":" + ((getMinute()<10)?("0"+getMinute()):(getMinute()));
}
Is a convenient but horribly bad way to fix your problem. As the other guys said, SimpleDateFormat is the answer :-)