-
Bug
-
Resolution: Not an Issue
-
P3
-
None
-
9, 10, 11
-
generic
-
generic
A DESCRIPTION OF THE PROBLEM :
The following ant target, which attempts to delete files that are 3 days old (or older), throws an error under Java 9 and 10:
<target name="-delete-old-log-files">
<tstamp>
<format property="old.file.stamp"
pattern="MM/dd/yyyy hh:mm a"
locale="en,UK"
offset="-3"
unit="day"/>
</tstamp>
<delete>
<fileset dir="${logging.dir}" includes="*/**">
<date datetime="${old.file.stamp}" when="before"/>
</fileset>
</delete>
</target>
Error thrown: "Date Cannot be parsed correctly. It should be in MM/DD/YYYY HH:MM AM_PM format"
There are no issues when executing the same ant target under Java 8.
REGRESSION : Last worked in version 8u172
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Build the Java program below with 1.8.0_172 and run under 1.8.0_172 and 10.0.1.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
long value
ACTUAL -
Exception in thread "main" java.text.ParseException: Unparseable date: "07/06/2018 10:56 AM"
at java.base/java.text.DateFormat.parse(DateFormat.java:395)
at Main.main(Main.java:10)
---------- BEGIN SOURCE ----------
import java.text.DateFormat;
import java.text.ParseException;
import java.util.Locale;
public class Main {
public static void main(final String[] args) throws ParseException {
final DateFormat df = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, Locale.US);
final long millis = df.parse("07/06/2018 10:56 AM").getTime();
System.out.println(millis);
}
}
---------- END SOURCE ----------
FREQUENCY : always
The following ant target, which attempts to delete files that are 3 days old (or older), throws an error under Java 9 and 10:
<target name="-delete-old-log-files">
<tstamp>
<format property="old.file.stamp"
pattern="MM/dd/yyyy hh:mm a"
locale="en,UK"
offset="-3"
unit="day"/>
</tstamp>
<delete>
<fileset dir="${logging.dir}" includes="*/**">
<date datetime="${old.file.stamp}" when="before"/>
</fileset>
</delete>
</target>
Error thrown: "Date Cannot be parsed correctly. It should be in MM/DD/YYYY HH:MM AM_PM format"
There are no issues when executing the same ant target under Java 8.
REGRESSION : Last worked in version 8u172
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Build the Java program below with 1.8.0_172 and run under 1.8.0_172 and 10.0.1.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
long value
ACTUAL -
Exception in thread "main" java.text.ParseException: Unparseable date: "07/06/2018 10:56 AM"
at java.base/java.text.DateFormat.parse(DateFormat.java:395)
at Main.main(Main.java:10)
---------- BEGIN SOURCE ----------
import java.text.DateFormat;
import java.text.ParseException;
import java.util.Locale;
public class Main {
public static void main(final String[] args) throws ParseException {
final DateFormat df = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, Locale.US);
final long millis = df.parse("07/06/2018 10:56 AM").getTime();
System.out.println(millis);
}
}
---------- END SOURCE ----------
FREQUENCY : always