Netcdf中时间的格式化

需求:获取到的时间格式为minutes since 2018-01-01 00:30:00

我想要的格式为2018-01-01 00:30:00

java代码如下

// 4° 设置时间变量
Variable timeObject = ncFile.findVariable("time");
String timeAt = timeObject.getUnitsString();
String regex = "\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}";
Pattern p = Pattern.compile(regex);
Matcher matcher = p.matcher(timeAt);
System.out.println(timeAt);
if (matcher.find()) {
    timeAt = matcher.group(0);
}
System.out.println(timeAt);

你可能感兴趣的:(netcdf)