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

📄 stringutil.java

📁 学习java+jsp的源码3
💻 JAVA
字号:
package bbs;

import java.sql.Date;
import java.text.DateFormat;
import java.sql.Timestamp;

public class StringUtil {

    /**
     * 寰楀埌褰撳墠绯荤粺鏃ユ湡鏃堕棿鐨勫瓧绗︿覆琛ㄧず 濡傦細"2003-08-21 12:23:56"
     * @return 褰撳墠绯荤粺鏃ユ湡鏃堕棿鐨勫瓧绗︿覆琛ㄧず
     */
    public static String getDateTime(Date date) {
        DateFormat mediumDateFormat = DateFormat.getDateTimeInstance(DateFormat.
            MEDIUM,
            DateFormat.
            MEDIUM);
        return mediumDateFormat.format(new java.util.Date(date.getTime()));
    }
    public static String getTimestamp(Timestamp date) {
        DateFormat mediumDateFormat = DateFormat.getDateTimeInstance(DateFormat.
            MEDIUM,
            DateFormat.
            MEDIUM);
        return mediumDateFormat.format(date);
    }

    public static String getBRString(String text) {
        if(text != null && text.indexOf("<") > -1){
            text = text.replaceAll("<","&lt;");
        }
        if(text != null && text.indexOf(">") > -1){
            text = text.replaceAll(">","&gt;");
        }
        if(text != null && text.indexOf("\n") > -1){
            text = text.replaceAll("\n", "<br>");
        }
        return text;
    }
    public static void main(String[]args) {
    }

}

⌨️ 快捷键说明

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