📄 codechange.java
字号:
/*
* Created on 2007-6-17
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package codechange;
/**
* @author yongyong
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class Codechange {
public Codechange() {
}
public static void main(String[] args) {
}
public static String toUnicode(String str){
try{
if(str==null)
str="";
else
str=new String(str.getBytes("GB2312"),"ISO-8859-1");
}catch(Exception e){System.out.println("In DealString toGB");e.printStackTrace();}
return str;
}
public static String toGB(String str){
try{
if(str==null)
str="";
else
str=new String(str.getBytes("ISO-8859-1"),"GB2312");
}catch(Exception e){System.out.println("In DealString toGB");e.printStackTrace();}
return str;
}
public static String replace(String source,String oldstr,String newstr){
StringBuffer output=new StringBuffer();
int lengthofSource=source.length();
int lengthofOldstr=oldstr.length();
int posStart=0;
int pos;
while((pos=source.indexOf(oldstr,posStart))>=0){
output.append(source.substring(posStart,pos));
output.append(newstr);
posStart=pos+lengthofOldstr;
}
if(posStart<lengthofSource){
output.append(source.substring(posStart));
}
return output.toString();
}
public static String getDateTime(){
java.text.SimpleDateFormat f=new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String time=f.format(new java.util.Date());
return time;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -