Java-取得服务器当前的各种具体时间
来源:互联网 发布:红叶知弦 编辑:程序博客网 时间:2024/05/17 06:15
/** * 取得服务器当前的各种具体时间 * 回车:日期时间 */import java.util.*;public class GetNowDate {Calendar calendar = null;public GetNowDate() {calendar = Calendar.getInstance();calendar.setTime(new Date());}public int getYear() {return calendar.get(Calendar.YEAR);}public int getMonth() {return 1 + calendar.get(Calendar.MONTH);}public int getDay() {return calendar.get(Calendar.DAY_OF_MONTH);}public int getHour() {return calendar.get(Calendar.HOUR_OF_DAY);}public int getMinute() {return calendar.get(Calendar.MINUTE);}public int getSecond() {return calendar.get(Calendar.SECOND);}public String getDate() {return getMonth() + "/" + getDay() + "/" + getYear();}public String getTime() {return getHour() + ":" + getMinute() + ":" + getSecond();}public String getDate2() {String yyyy = "0000", mm = "00", dd = "00";yyyy = yyyy + getYear();mm = mm + getMonth();dd = dd + getDay();yyyy = yyyy.substring(yyyy.length() - 4);mm = mm.substring(mm.length() - 2);dd = dd.substring(dd.length() - 2);return yyyy + "/" + mm + "/" + dd;}public String getTime2() {String hh = "00", mm = "00", ss = "00";hh = hh + getHour();mm = mm + getMinute();ss = ss + getSecond();hh = hh.substring(hh.length() - 2, hh.length());mm = mm.substring(mm.length() - 2, mm.length());ss = ss.substring(ss.length() - 2, ss.length());return hh + ":" + mm + ":" + ss;}}
0 0
- 取得服务器当前的各种具体时间
- Java-取得服务器当前的各种具体时间
- java 取得当前时间的前几天
- 用java取得当前时间
- 用java取得当前时间
- java一句话取得当前系统时间的前一天
- php取得当前时间函数(取到的是服务器的时间)
- 无刷新随时取得当前服务器时间用户登陆时间,在线时间,空闲时间并自动退出的例子
- 取得当前时间的年或者月:
- 取得当前时间的前七天
- C取得时间的各种方法
- 取得系统当前时间
- 取得系统当前时间
- 取得系统当前时间
- 取得当前时间
- Android 取得当前时间
- Java中输出当前时间的各种方法(较齐全)
- Java中输出当前时间的各种方法
- libpoco在mac平台编译详解
- Extjs+PHP 文件下载
- 常用网络工具
- swift快速入门,三分钟上手
- 浅析GLib
- Java-取得服务器当前的各种具体时间
- 磁场强度简介
- OOAD作业---设计模式---装饰者模式
- DWR学习2-回调函数异步问题
- 数据结构——算法之(025)( 求一个数组的最长递减子序列)
- 利用Cookie显示用户上次访问网站的时间
- Redis应用场景
- ActiveMQ安装与运行
- CHD4安装hadoop2.0