我需要转变
String[] args = {"--path=C:/log", "--time=hourly"};
Run Code Online (Sandbox Code Playgroud)
成
String[] args = {"--path", "C:/log", "--time", "hourly"};
Run Code Online (Sandbox Code Playgroud)
我怎样才能以优雅的方式在Java 8中做到这一点?
List<String> newArgs = Lists.newArrayList();
for (String s : args) {
String[] split = s.split("=");
newArgs.add(split[0]);
newArgs.add(split[1]);
}
String[] strarray = new String[newArgs.size()];
return newArgs.toArray(strarray);
Run Code Online (Sandbox Code Playgroud) 我在grails映射中有2个实体
产品和资产
我需要获得产品ID等于x且资产类型等于y的资产
我试过了
Asset.findByProductIdAndAssetType(productId, assetType)
Run Code Online (Sandbox Code Playgroud)
但不起作用
独特的解决方案是
按ID加载产品,按产品加载查找
def product = Product.findById(productId)
Asset.findByProductAndAssetType(product, assetType)
Run Code Online (Sandbox Code Playgroud)
有没有办法只使用productId加载资产?
我有此代码可以在日期 Java 8 中添加 1 小时或 1 天,但不起作用
String DATE_FORMAT = "yyyy-MM-dd HH:mm:ss";
java.text.SimpleDateFormat format = new java.text.SimpleDateFormat(DATE_FORMAT);
Date parse = format.parse("2017-01-01 13:00:00");
LocalDateTime ldt = LocalDateTime.ofInstant(parse.toInstant(), ZoneId.systemDefault());
ldt.plusHours(1);
ZonedDateTime zdt = ldt.atZone(ZoneId.systemDefault());
Date te = Date.from(zdt.toInstant());
Run Code Online (Sandbox Code Playgroud)
怎么了?代码显示:Sun Jan 01 13:00:00 BRST 2017