javaRoadMap_4java常用实体类

本文介绍了Java中常用的实体类,包括系统级类的操作方法、字符串处理类的区别与应用场景、以及日期处理类的使用技巧。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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();
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值