java - 在java中获取ResultTable []的第一个元素
问题描述
这些代码:
String genType = FileConstants.CHANGE_CYCLE;
ResultTable[] genericCode = RTManager.getRTCsmGenericCodesDecodeList(genType);
String genCode = Arrays.toString(genericCode);
返回这些值:
genCode = [[code=22:00:00]
[dCode=Cut-off time for change bill_cycle if existing cycle_close_date=activity_date]]
问题:我如何获取 only'22:00:00'
并将其转换为Time datatype
?
解决方案
如果 ResultTable 数组中的项目有一个 toString() 并且它产生字符串,那么你可以像这样得到它。
genericCode[0].toString().split("=")[1]
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
public class DateExample {
public static void main(String[] args) {
String time = "22:00:00";
SimpleDateFormat sdf = new SimpleDateFormat("hh:mm:ss");
Date date;
try {
date = sdf.parse(time);
System.out.println("Time: " + sdf.format(date));
} catch (ParseException e) {
e.printStackTrace();
}
}
}
推荐阅读
- angular - 使用 agm npm 包在 Angular 7 中添加多条折线
- java - @JsonIdentityInfo serialization of items
- fbx - DirectX 12 中 Assimp 的骨骼动画错误
- django - 在 Django Admin 中禁止关于 on_delete=CASCADE 的警告
- reactjs - 类型“{}”不可分配给类型“IPops”
- macos - 如何使用 GHC/stack 在 macOS 上创建本机 ARM 可执行文件
- python - 当我提到它时,如何让我的不和谐机器人显示它的前缀(python)
- angular - 错误:类型 r 没有 'ɵmod' 属性。角
- c# - 基于令牌的身份验证返回状态 0
- javascript - 如何在 React JS 中动态添加子数组输入字段