MM/DD/yyyy、M/D/yyyy、またはいくつかの組み合わせの日付を解析する簡単な方法はありますか? つまり、1 桁の日または月の前のゼロはオプションです。
手動で行うには、次を使用できます。
String[] dateFields = dateString.split("/");
int month = Integer.parseInt(dateFields[0]);
int day = Integer.parseInt(dateFields[1]);
int year = Integer.parseInt(dateFields[2]);
そして、次のように検証します。
dateString.matches("\\d\\d?/\\d\\d?/\\d\\d\\d\\d")
これを処理する SimpleDateFormat または JodaTime への呼び出しはありますか?