java常用实体类
1. Java系统级类
System.getProperties(): 得到所有系统属性
System.getProperties(key): 取得某个属性值
System.setProperties(Properties props): 设置多个系统属性
System.clearProperties(key): 移除某个属性
System.getenv(): 获得环境变量
System.getenv(key):获得某个环境变量
Runtime.getRuntime().load(path of lib file): 加载动态库或系统库名
System.load(path of lib file): 等同上一个
Runtime.getRuntime().loadLibrary(libfile)
System.loadLibrary(libfile)
System.currentTimeMillis():取得当前时间
System.nanoTime():取得当前时间以毫微秒为单位
Runtime.getRuntime().exit(n):退出系统, 关闭JVM, 非0参数为非正常退出。
System.exit(n): 同上
Runtime.getRuntime().exec("cmd /c start Winword"): 打开word
Runtime.getRuntime().exec("cmd /C start d:/run.bat"): 运行批处理文件
2. 字符串处理类
2.1 String, StringBuffer, StringBuilder
String: 字符长常量,在少量且固定的串联时便于使用
StringBuffer: 字符串变量,适用于频繁串联,且多线程环境中。
StringBuilder: 字符创变量,适用于频繁串联,且单线程环境中。
3. 日期处理
3.1 SimpleDateFormat
Date date = new Date();
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
System.out.println(format.format(date));
3.2 Calendar
日期需要使用Calendar:
Calendar now = Calendar.getInstance();
Date current = now.getTime();
1. Java系统级类
System.getProperties(): 得到所有系统属性
System.getProperties(key): 取得某个属性值
System.setProperties(Properties props): 设置多个系统属性
System.clearProperties(key): 移除某个属性
System.getenv(): 获得环境变量
System.getenv(key):获得某个环境变量
Runtime.getRuntime().load(path of lib file): 加载动态库或系统库名
System.load(path of lib file): 等同上一个
Runtime.getRuntime().loadLibrary(libfile)
System.loadLibrary(libfile)
System.currentTimeMillis():取得当前时间
System.nanoTime():取得当前时间以毫微秒为单位
Runtime.getRuntime().exit(n):退出系统, 关闭JVM, 非0参数为非正常退出。
System.exit(n): 同上
Runtime.getRuntime().exec("cmd /c start Winword"): 打开word
Runtime.getRuntime().exec("cmd /C start d:/run.bat"): 运行批处理文件
2. 字符串处理类
2.1 String, StringBuffer, StringBuilder
String: 字符长常量,在少量且固定的串联时便于使用
StringBuffer: 字符串变量,适用于频繁串联,且多线程环境中。
StringBuilder: 字符创变量,适用于频繁串联,且单线程环境中。
3. 日期处理
3.1 SimpleDateFormat
Date date = new Date();
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
System.out.println(format.format(date));
3.2 Calendar
日期需要使用Calendar:
Calendar now = Calendar.getInstance();
Date current = now.getTime();