获取String类型的日期和时间

package project100919; import java.util.Calendar; class ShowTime { private Calendar t; private int y, m, d, hh, mm, ss; ShowTime() { t = Calendar.getInstance(); y = t.get(t.YEAR); m = t.get(t.MONTH) + 1; d = t.get(t.DATE); hh = t.get(t.HOUR); mm = t.get(t.MINUTE); ss = t.get(t.SECOND); } public String getDate() { return y + "年" + m + "月" + d + "日"; } public String getTime() { return hh + "时" + mm + "分" + ss + "秒"; } }  

你可能感兴趣的:(获取String类型的日期和时间)