用SimpleDateFormat类的构造方法即可,代码如下
Date d = c.getTime();
SimpleDateFormat sdf = new SimpleDateFormat ("hh:mm:ss");
String time = sdf.format(d);作者: 孙沛 时间: 2012-8-30 21:22
import java.util.*;
import java.text.*;
class CalendarTest
{
public static void main(String[] args)
{
//2
Calendar c2 = Calendar.getInstance();
c2.add(Calendar.DAY_OF_MONTH,-1);
SimpleDateFormat sdf = new SimpleDateFormat("",Locale.SIMPLIFIED_CHINESE);
sdf.applyPattern("HH时mm分ss秒");
String timeStr = sdf.format(c2.getTime());
System.out.println(timeStr);