现在的位置: 首页 > 综合 > 正文

日期工具类

2013年08月13日 ⁄ 综合 ⁄ 共 639字 ⁄ 字号 评论关闭
package com.example.testandroid;
import java.text.SimpleDateFormat;
public class DateUtil {
 //得到当前的详细时间(精确到秒)
 public static String getCurrentDetailTime() {
  SimpleDateFormat sDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
  String date = sDateFormat.format(new java.util.Date());
  return date;
 }
 //得到当前时间(精确到分)
 public static String getCurrentTimeToMin() {
  SimpleDateFormat sDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm");
  String date = sDateFormat.format(new java.util.Date());
  return date;
 }
 //得到当前时间(精确到天)
 public static String getCurrentTimeToDay() {
  SimpleDateFormat sDateFormat = new SimpleDateFormat("yyyy-MM-dd");
  String date = sDateFormat.format(new java.util.Date());
  return date;
 }
}

抱歉!评论已关闭.