⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 caltime.java

📁 短信平台CMPP30 的JAVA程序,(含SQL数据库)
💻 JAVA
字号:
// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi 
// Source File Name:   Caltime.java

package com.SMGP13.loginUtil;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class Caltime
{

    public static final int YYMMDDhh = 8;
    public static final int YYMMDDhhmm = 10;
    public static final int YYMMDDhhmmss = 12;
    public static final int YYMMDDhhmmssxxx = 15;
    public static final int YYYYMMDDhhmmss = 14;

    public Caltime()
    {
    }

    public static String getDate()
    {
        Date currentTime = new Date();
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String dateString = formatter.format(currentTime);
        return dateString;
    }

    private static synchronized String getFormatTime(int time, int format)
    {
        StringBuffer numm = new StringBuffer();
        int length = String.valueOf(time).length();
        if(format < length)
            return null;
        for(int i = 0; i < format - length; i++)
            numm.append("0");

        numm.append(time);
        return numm.toString().trim();
    }

    public static String getStringDate()
    {
        Date currentTime = new Date();
        SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd");
        String dateString = formatter.format(currentTime);
        return dateString;
    }

    public static synchronized String getTime(int format)
    {
        StringBuffer cTime = new StringBuffer(10);
        Calendar time = Calendar.getInstance();
        int miltime = time.get(14);
        int second = time.get(13);
        int minute = time.get(12);
        int hour = time.get(11);
        int day = time.get(5);
        int month = time.get(2) + 1;
        int year = time.get(1);
        if(format != 14)
        {
            if(year >= 2000)
                year -= 2000;
            else
                year -= 1900;
        }
        if(format >= 2)
        {
            if(format == 14)
                cTime.append(year);
            else
                cTime.append(getFormatTime(year, 2));
        }
        if(format >= 4)
            cTime.append(getFormatTime(month, 2));
        if(format >= 6)
            cTime.append(getFormatTime(day, 2));
        if(format >= 8)
            cTime.append(getFormatTime(hour, 2));
        if(format >= 10)
            cTime.append(getFormatTime(minute, 2));
        if(format >= 12)
            cTime.append(getFormatTime(second, 2));
        if(format >= 15)
            cTime.append(getFormatTime(miltime, 3));
        return cTime.toString();
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -