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

📄 util.java

📁 网上论坛系统,是一个功能很完善的系统,推存给大家,很好用的
💻 JAVA
字号:
package util;

import java.io.UnsupportedEncodingException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Util {
    public Util() {
        super();
    }

    public static String convertEncoding(String old) {
        try {
            return new String(old.getBytes("ISO8859-1"));
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
            return "编码转化出错!";
        }
    }
    /**
     * 将日期转化为字符串
     * @param date
     * @return
     */
    public static String date2String(java.util.Date date) {
        if (date == null)
            return "";

        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        //DateFormat dateFormat = DateFormat.getDateInstance();
        return sdf.format(date);
    }
    /**
     * 将日期转化为指定格式的字符串
     * @param date Date
     * @param format String
     * @return String
     */
    public static String date2String(java.util.Date date,String format) {
        if (date == null)
            return "";

        SimpleDateFormat sdf = new SimpleDateFormat(format);
        //DateFormat dateFormat = DateFormat.getDateInstance();
        return sdf.format(date);
    }

    public static Date getCurrentDate(){
        return new Date(System.currentTimeMillis());
    }
}

⌨️ 快捷键说明

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