没有合适的资源?快使用搜索试试~ 我知道了~
本文实例为大家分享了Android处理时间的各种方法,供大家参考,具体内容如下 /** * 获取当前时间 * * @return 当前时间 */ public static String getdate() { SimpleDateFormat formatter = new SimpleDateFormat(HH:mm); Date curDate = new Date(System.currentTimeMillis());// 获取当前时间 String time = formatter.format(curDate);
资源详情
资源评论
资源推荐
Android处理时间各种方法汇总处理时间各种方法汇总
本文实例为大家分享了Android处理时间的各种方法,供大家参考,具体内容如下
/**
* 获取当前时间
*
* @return 当前时间
*/
public static String getdate() {
SimpleDateFormat formatter = new SimpleDateFormat("HH:mm");
Date curDate = new Date(System.currentTimeMillis());// 获取当前时间
String time = formatter.format(curDate);
return time;
}
/**
* 获取当前秒数
* @return
*/
public static String getSecond(){
Calendar calendar = Calendar.getInstance();
int sec = calendar.get(Calendar.SECOND);
String value = String.valueOf(sec<10?"0"+sec:sec);
return value;
}
/**
* 获取当天日期
*
* @return 当前时间
*/
public static String getriqi() {
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
Date curDate = new Date(System.currentTimeMillis());// 获取当天日期
String time = formatter.format(curDate);
return time;
}
/**
* 获取当前全部时间
*
* @return 当前时间
*/
public static String getalldate() {
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date curDate = new Date(System.currentTimeMillis());// 获取当前时间
String time = formatter.format(curDate);
return time;
}
public static Date getDate(String time){
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date = null;
try {
date = formatter.parse(time);
} catch (ParseException e) {
e.printStackTrace();
}
return date;
}
/**
* 天数减一
*/
public static String Yesterday(int data) {
SimpleDateFormat dft = new SimpleDateFormat("yyyy-MM-dd");
Date beginDate = new Date();
Calendar date = Calendar.getInstance();
date.setTime(beginDate);
date.set(Calendar.DATE, date.get(Calendar.DATE) - data);
// Date endDate = dft.parse(dft.format(date.getTime()));
weixin_38680492
- 粉丝: 5
- 资源: 932
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 维伦触摸屏开机初始化和自动返回主界面
- (精品)通信电源培训教材-理论知识.ppt
- 基于python开发一个支持多用户在线的FTP程序
- python:编写数据分析代码 生成数据,写入表格,从表格中读取数据,数据展示,数据排序 计算数据最大值,最小值,均值,中位数
- (考研复试)数据库笔记.doc
- Java开发的实验教学平台.rar
- 矩阵运算-基于numpy矩阵运算实现ESTI-CS算法.zip
- TI杯大奖赛本科组+研究生组论文+源代码+PCB基于msp430的智能宿舍
- 圆三角形矩形检测数据集VOC+YOLO格式228张3类别.7z
- TI杯大奖赛本科组+研究生组论文+源代码+PCB基于MSP430的智能电能表设计
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0