[英]Need to save the excel file for every run with the current timestamp
I am using the below code to convert the json file to excel using aspose.我正在使用下面的代码使用 aspose 将 json 文件转换为 excel。 I am able to convert the json file but i need to save the converted file for every run with the current timestamp and i need to run it daily so that it should create a folder daily with the date.
我能够转换 json 文件,但我需要使用当前时间戳为每次运行保存转换后的文件,我需要每天运行它,以便它应该每天创建一个包含日期的文件夹。
public class converter1 {
public static void main(String[] args) throws Exception {
LocalDateTime date = LocalDateTime.now();
DateTimeFormatter dateformat = DateTimeFormatter.ofPattern("dd-MM-yyyy HH-mm-ss");
String formatedate =date.format(dateformat);
Workbook workbook = new Workbook(".//Files//output.json");
workbook.save(".//output-"+formatedate+".xlsx");
System.out.println("json file converted successfully");
}
} }
Maybe you could try:也许你可以试试:
eg例如
Sample code:示例代码:
LocalDateTime date = LocalDateTime.now();
java.time.format.DateTimeFormatter dateformat = java.time.format.DateTimeFormatter.ofPattern("dd-MM-yyyy");
String formatedate = date.format(dateformat);
java.time.format.DateTimeFormatter datetimeformat = java.time.format.DateTimeFormatter.ofPattern("dd-MM-yyyy HH-mm-ss");
String formatedatetime = date.format(datetimeformat);
Workbook workbook = new Workbook(".//Files//output.json");
File file = new File(".//" + formatedate);
if (!file.exists())
{
file.mkdir();
}
workbook.save(file.getPath()+ "//output-"+formatedatetime+".xlsx");
System.out.println("json file converted successfully");
PS.附言。 I am working as Support developer/ Evangelist at Aspose.
我在 Aspose 担任支持开发人员/传播者。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.