R
renyi
Unregistered / Unconfirmed
GUEST, unregistred user!
下面的这个程序什么都有:(注:SUN建议不使用Date类)
import java.util.*;
class CalendarDemo
{
public static void main(String args[])
{
int year,month,day,hour,minute,second,millisecond;
Calendar nowDate = Calendar.getInstance();
StringBuffer strDate = new StringBuffer();
year = nowDate.get(Calendar.YEAR);
month = nowDate.get(Calendar.MONTH)+1;
day = nowDate.get(Calendar.DAY_OF_MONTH);
hour = nowDate.get(Calendar.HOUR);
minute = nowDate.get(Calendar.MINUTE);
second = nowDate.get(Calendar.SECOND);
millisecond = nowDate.get(Calendar.MILLISECOND);
strDate.append(year);
if (month>9)
strDate.append(month);
else
strDate.append("0"+month);
if (day>9)
strDate.append(day);
else
strDate.append("0"+day);
if (hour>9)
strDate.append(hour);
else
strDate.append("0"+hour);
if (minute>9)
strDate.append(minute);
else
strDate.append("0"+minute);
if (second>9)
strDate.append(second);
else
strDate.append("0"+second);
strDate.append(millisecond);
System.out.println(strDate);
}
}
import java.util.*;
class CalendarDemo
{
public static void main(String args[])
{
int year,month,day,hour,minute,second,millisecond;
Calendar nowDate = Calendar.getInstance();
StringBuffer strDate = new StringBuffer();
year = nowDate.get(Calendar.YEAR);
month = nowDate.get(Calendar.MONTH)+1;
day = nowDate.get(Calendar.DAY_OF_MONTH);
hour = nowDate.get(Calendar.HOUR);
minute = nowDate.get(Calendar.MINUTE);
second = nowDate.get(Calendar.SECOND);
millisecond = nowDate.get(Calendar.MILLISECOND);
strDate.append(year);
if (month>9)
strDate.append(month);
else
strDate.append("0"+month);
if (day>9)
strDate.append(day);
else
strDate.append("0"+day);
if (hour>9)
strDate.append(hour);
else
strDate.append("0"+hour);
if (minute>9)
strDate.append(minute);
else
strDate.append("0"+minute);
if (second>9)
strDate.append(second);
else
strDate.append("0"+second);
strDate.append(millisecond);
System.out.println(strDate);
}
}