📄 stringutil.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("<","<");
}
if(text != null && text.indexOf(">") > -1){
text = text.replaceAll(">",">");
}
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 + -