日付の文字列を日付に解析しようとしています。 I私はコード実行中に、私はこの出力を取得しています上記の入力文字列 の間違った出力を取得しています、コード日付の変換中に間違った日付を取得しています
public class convertDate
{
public static void main(String args[])
{
String strlastruntime ="16/06/2016 9:17:00 AM",dateFormat ="MM/dd/yyyy hh:mm:ss a";
try
{
strlastruntime = strlastruntime.trim();
System.out.println("strlastruntime = "+strlastruntime+" dateFormat = "+dateFormat);
java.util.Locale l = java.util.Locale.US;
java.text.SimpleDateFormat formatter = new java.text.SimpleDateFormat(dateFormat,l);
//System.out.println("formatter = "+formatter);
java.util.Date date = formatter.parse(strlastruntime);
System.out.println("date = "+date);
long time = date.getTime();
System.out.println("time = "+time);
}
catch(java.text.ParseException ee)
{
ee.printStackTrace();
System.out.println(ee);
}
}
}
次試みたが、している:だから
strlastruntime = 16/06/2016 9:17:00 AM dateFormat = MM/dd/yyyy hh:mm:ss a
date = Thu Apr 06 09:17:00 IST 2017
time = 1491450420000
を、見つけるために私を助けてくださいソリューション..
何の出力あなたの代わりに期待したのですか? –