package 时间日期格式的转换;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Locale;
import java.util.Scanner;

public class Main {


public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int n = Integer.parseInt(input.nextLine());
SimpleDateFormat df1 = new SimpleDateFormat("yyyy/MM/dd-HH:mm:ss",Locale.US);
SimpleDateFormat df2 = new SimpleDateFormat("MM/dd/yyyy-hh:mm:ssa",Locale.US);

for(int i=0;i<n;i++)
{
String s = input.nextLine();
try {
System.out.println(df2.format(df1.parse(s)).toLowerCase());
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}



}

}

测试结果:

2
2009/11/07-12:12:12
11/07/2009-12:12:12pm
1970/01/01-00:01:01
01/01/1970-12:01:01am

 

转载于:https://www.cnblogs.com/aicpcode/p/4402504.html

Logo

昇腾计算产业是基于昇腾系列(HUAWEI Ascend)处理器和基础软件构建的全栈 AI计算基础设施、行业应用及服务,https://devpress.csdn.net/organization/setting/general/146749包括昇腾系列处理器、系列硬件、CANN、AI计算框架、应用使能、开发工具链、管理运维工具、行业应用及服务等全产业链

更多推荐