时间日期格式的转换

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

 

posted on 2015-04-08 15:15  aicpcode  阅读(175)  评论(0编辑  收藏  举报

导航