首页>代码>安卓在线聊天项目实例(含简易服务器--套接字编程)>/安卓在线聊天安卓端和服务端源代码/android/app/src/main/java/com/king/anetty/app/tools/DateTools.java
package com.king.anetty.app.tools;

import java.util.Calendar;

/**
 * @author 高金磊
 * @version 1.0
 * @date 2019/12/15 11:44
 * @项目名 android_last
 */
public class DateTools {
    private Calendar calendar;
    private int year;
    private int month;
    private int day;
    private int hour;
    private int minute;
    private int second;

    //禁止外部直接初始化以免拿到老版本的日期对象
    private DateTools() {
        calendar = Calendar.getInstance();
        year = calendar.get(Calendar.YEAR);
        month = calendar.get(Calendar.MONTH)+1;
        day = calendar.get(Calendar.DAY_OF_MONTH);
        hour = calendar.get(Calendar.HOUR_OF_DAY);
        minute = calendar.get(Calendar.MINUTE);
        second = calendar.get(Calendar.SECOND);
    }

    private Calendar getCalendar() {
        return calendar;
    }
    public static String getDate(){
        //保证每次获取的是最新的
        DateTools date=new DateTools();
        return ""+date.getMonth()+"-"+date.day+"  "+date.getHour()+":"+date.getMinute();
    }
    private int getYear() {
        return year;
    }

    private int getMonth() {
        return month;
    }

    private int getDay() {
        return day;
    }

    private int getHour() {
        return hour;
    }

    private int getMinute() {
        return minute;
    }

    private int getSecond() {
        return second;
    }
}
最近下载更多
1623096142  LV6 2022年5月27日
vvcvv_cool  LV8 2022年5月3日
26504727816  LV1 2021年7月14日
mudingc木钉  LV30 2021年7月7日
ssr123  LV8 2021年6月28日
xhy2740354020  LV7 2021年6月1日
ahdaudha  LV7 2021年4月9日
在云端i  LV9 2021年3月16日
Zuo2001  LV4 2021年1月13日
1525448324  LV8 2020年12月14日
最近浏览更多
heweimin  LV12 昨天
不止是六位数  LV7 2023年12月21日
yhwyhw1  LV2 2023年12月21日
郑唯希 2023年11月28日
暂无贡献等级
Mhdpig  LV3 2023年11月18日
3334004690  LV3 2023年10月18日
wanfeng_233  LV4 2023年8月29日
panwill  LV4 2023年8月18日
yyyyyyzh  LV8 2023年6月11日
我真不会打篮球  LV1 2023年6月3日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友