- 14.5k
- 3
- 33
- 56
Java (OpenJDK 8), 193190 + 26 = 219216 bytes
import java.time.format.*;
s->DateTimeFormatter.ofPattern("uuuu/MM/dd").format(DateTimeFormatter.ofPattern("[EEEE, ][d ]MMMM [d, ]uuuu").withResolverStyle(ResolverStyle.STRICT).parse(s.replaceAll("st|rd|th|"(2\\d)nd"[a-z].","1ドル")))
Important note: it was shorter to also validate the day of week instead of ditching it, so that validation is included!
I haven't tried with SimpleDateFormat beyond the obvious cases which all accepted dates like 30 February. So I had to ditch it and I used Java 8's DateTimeFormatter.
Explanation
"[EEEE, ][d ]MMMM [d, ]uuuu"
This format means :
- optional day-of-week followed by comma and space
[EEEE, ](happens inSunday, ...), - followed by optional day with space
[d ], - followed by month in full letters
MMMMand space, - followed by optional day with comma and space
[d, ], - followed by year of era
uuuuto let the parser know we're in Gregorian era.
Code:
import java.time.format.*; // Required for DateTimeFormatter, *and* ResolverStyle
s->DateTimeFormatter.ofPattern("uuuu/MM/dd") // Output format
.format(
DateTimeFormatter.ofPattern("[EEEE, ][d ]MMMM [d, ]uuuu") // Input format
.withResolverStyle(ResolverStyle.STRICT) // Invalidates xxxx-02-30 instead of transforming it into xxxx-02-28
.parse(
s.replaceAll("st|rd|th|"(2\\d)nd"[a-z].","1ドル") // remove useless stuff around the date, special case for// "nd"remove st, nd, rd, th
)
)
Credits
- 2 bytes in the regex thanks to Neil.
Java (OpenJDK 8), 193 + 26 = 219 bytes
import java.time.format.*;
s->DateTimeFormatter.ofPattern("uuuu/MM/dd").format(DateTimeFormatter.ofPattern("[EEEE, ][d ]MMMM [d, ]uuuu").withResolverStyle(ResolverStyle.STRICT).parse(s.replaceAll("st|rd|th|(2)nd","1ドル")))
Important note: it was shorter to also validate the day of week instead of ditching it, so that validation is included!
I haven't tried with SimpleDateFormat beyond the obvious cases which all accepted dates like 30 February. So I had to ditch it and I used Java 8's DateTimeFormatter.
Explanation
"[EEEE, ][d ]MMMM [d, ]uuuu"
This format means :
- optional day-of-week followed by comma and space
[EEEE, ](happens inSunday, ...), - followed by optional day with space
[d ], - followed by month in full letters
MMMMand space, - followed by optional day with comma and space
[d, ], - followed by year of era
uuuuto let the parser know we're in Gregorian era.
Code:
import java.time.format.*; // Required for DateTimeFormatter, *and* ResolverStyle
s->DateTimeFormatter.ofPattern("uuuu/MM/dd") // Output format
.format(
DateTimeFormatter.ofPattern("[EEEE, ][d ]MMMM [d, ]uuuu") // Input format
.withResolverStyle(ResolverStyle.STRICT) // Invalidates xxxx-02-30 instead of transforming it into xxxx-02-28
.parse(
s.replaceAll("st|rd|th|(2)nd","1ドル") // remove useless stuff around the date, special case for "nd"
)
)
Credits
- 2 bytes in the regex thanks to Neil.
Java (OpenJDK 8), 190 + 26 = 216 bytes
import java.time.format.*;
s->DateTimeFormatter.ofPattern("uuuu/MM/dd").format(DateTimeFormatter.ofPattern("[EEEE, ][d ]MMMM [d, ]uuuu").withResolverStyle(ResolverStyle.STRICT).parse(s.replaceAll("(\\d)[a-z].","1ドル")))
Important note: it was shorter to also validate the day of week instead of ditching it, so that validation is included!
I haven't tried with SimpleDateFormat beyond the obvious cases which all accepted dates like 30 February. So I had to ditch it and I used Java 8's DateTimeFormatter.
Explanation
"[EEEE, ][d ]MMMM [d, ]uuuu"
This format means :
- optional day-of-week followed by comma and space
[EEEE, ](happens inSunday, ...), - followed by optional day with space
[d ], - followed by month in full letters
MMMMand space, - followed by optional day with comma and space
[d, ], - followed by year of era
uuuuto let the parser know we're in Gregorian era.
Code:
import java.time.format.*; // Required for DateTimeFormatter, *and* ResolverStyle
s->DateTimeFormatter.ofPattern("uuuu/MM/dd") // Output format
.format(
DateTimeFormatter.ofPattern("[EEEE, ][d ]MMMM [d, ]uuuu") // Input format
.withResolverStyle(ResolverStyle.STRICT) // Invalidates xxxx-02-30 instead of transforming it into xxxx-02-28
.parse(
s.replaceAll("(\\d)[a-z].","1ドル") // remove st, nd, rd, th
)
)
Credits
- 2 bytes in the regex thanks to Neil.
- 14.5k
- 3
- 33
- 56
Java (OpenJDK 8), 185193 + 26 = 211219 bytes
import java.time.format.*;
s->DateTimeFormatter.ofPattern("uuuu/MM/dd").format(DateTimeFormatter.ofPattern("[EEEE, ][d ]MMMM [d, ]uuuu").withResolverStyle(ResolverStyle.STRICT).parse(s.replaceAll("st|rd|th""st|rd|th|(2)nd","""1ドル")))
Important note: it was shorter to also validate the day of week instead of ditching it, so that validation is included!
I haven't tried with SimpleDateFormat beyond the obvious cases which all accepted dates like 30 February. So I had to ditch it and I used Java 8's DateTimeFormatter.
Explanation
"[EEEE, ][d ]MMMM [d, ]uuuu"
This format means :
- optional day-of-week followed by comma and space
[EEEE, ](happens inSunday, ...), - followed by optional day with space
[d ], - followed by month in full letters
MMMMand space, - followed by optional day with comma and space
[d, ], - followed by year of era
uuuuto let the parser know we're in Gregorian era.
Code:
import java.time.format.*; // Required for DateTimeFormatter, *and* ResolverStyle
s->DateTimeFormatter.ofPattern("uuuu/MM/dd") // Output format
.format(
DateTimeFormatter.ofPattern("[EEEE, ][d ]MMMM [d, ]uuuu") // Input format
.withResolverStyle(ResolverStyle.STRICT) // Invalidates xxxx-02-30 instead of transforming it into xxxx-02-28
.parse(
s.replaceAll("st|rd|th""st|rd|th|(2)nd","""1ドル") // remove useless stuff around the date, special case for "nd"
)
)
Credits
- 2 bytes in the regex thanks to Neil.
Java (OpenJDK 8), 185 + 26 = 211 bytes
import java.time.format.*;
s->DateTimeFormatter.ofPattern("uuuu/MM/dd").format(DateTimeFormatter.ofPattern("[EEEE, ][d ]MMMM [d, ]uuuu").withResolverStyle(ResolverStyle.STRICT).parse(s.replaceAll("st|rd|th","")))
Important note: it was shorter to also validate the day of week instead of ditching it, so that validation is included!
I haven't tried with SimpleDateFormat beyond the obvious cases which all accepted dates like 30 February. So I had to ditch it and I used Java 8's DateTimeFormatter.
Explanation
"[EEEE, ][d ]MMMM [d, ]uuuu"
This format means :
- optional day-of-week followed by comma and space
[EEEE, ](happens inSunday, ...), - followed by optional day with space
[d ], - followed by month in full letters
MMMMand space, - followed by optional day with comma and space
[d, ], - followed by year of era
uuuuto let the parser know we're in Gregorian era.
Code:
import java.time.format.*; // Required for DateTimeFormatter, *and* ResolverStyle
s->DateTimeFormatter.ofPattern("uuuu/MM/dd") // Output format
.format(
DateTimeFormatter.ofPattern("[EEEE, ][d ]MMMM [d, ]uuuu") // Input format
.withResolverStyle(ResolverStyle.STRICT) // Invalidates xxxx-02-30 instead of transforming it into xxxx-02-28
.parse(
s.replaceAll("st|rd|th","") // remove useless stuff around the date
)
)
Credits
- 2 bytes in the regex thanks to Neil.
Java (OpenJDK 8), 193 + 26 = 219 bytes
import java.time.format.*;
s->DateTimeFormatter.ofPattern("uuuu/MM/dd").format(DateTimeFormatter.ofPattern("[EEEE, ][d ]MMMM [d, ]uuuu").withResolverStyle(ResolverStyle.STRICT).parse(s.replaceAll("st|rd|th|(2)nd","1ドル")))
Important note: it was shorter to also validate the day of week instead of ditching it, so that validation is included!
I haven't tried with SimpleDateFormat beyond the obvious cases which all accepted dates like 30 February. So I had to ditch it and I used Java 8's DateTimeFormatter.
Explanation
"[EEEE, ][d ]MMMM [d, ]uuuu"
This format means :
- optional day-of-week followed by comma and space
[EEEE, ](happens inSunday, ...), - followed by optional day with space
[d ], - followed by month in full letters
MMMMand space, - followed by optional day with comma and space
[d, ], - followed by year of era
uuuuto let the parser know we're in Gregorian era.
Code:
import java.time.format.*; // Required for DateTimeFormatter, *and* ResolverStyle
s->DateTimeFormatter.ofPattern("uuuu/MM/dd") // Output format
.format(
DateTimeFormatter.ofPattern("[EEEE, ][d ]MMMM [d, ]uuuu") // Input format
.withResolverStyle(ResolverStyle.STRICT) // Invalidates xxxx-02-30 instead of transforming it into xxxx-02-28
.parse(
s.replaceAll("st|rd|th|(2)nd","1ドル") // remove useless stuff around the date, special case for "nd"
)
)
Credits
- 2 bytes in the regex thanks to Neil.
Java (OpenJDK 8), 187185 + 26 = 213211 bytes
import java.time.format.*;
s->DateTimeFormatter.ofPattern("uuuu/MM/dd").format(DateTimeFormatter.ofPattern("[EEEE, ][d ]MMMM [d, ]uuuu").withResolverStyle(ResolverStyle.STRICT).parse(s.replaceAll("(st|rd|th)""st|rd|th","")))
Important note: it was shorter to also validate the day of week instead of ditching it, so that validation is included!
I haven't tried with SimpleDateFormat beyond the obvious cases which all accepted dates like 30 February. So I had to ditch it and I used Java 8's DateTimeFormatter.
Explanation
"[EEEE, ][d ]MMMM [d, ]uuuu"
This format means :
- optional day-of-week followed by comma and space
[EEEE, ](happens inSunday, ...), - followed by optional day with space
[d ], - followed by month in full letters
MMMMand space, - followed by optional day with comma and space
[d, ], - followed by year of era
uuuuto let the parser know we're in Gregorian era.
Code:
import java.time.format.*; // Required for DateTimeFormatter, *and* ResolverStyle
s->DateTimeFormatter.ofPattern("uuuu/MM/dd") // Output format
.format(
DateTimeFormatter.ofPattern("[EEEE, ][d ]MMMM [d, ]uuuu") // Input format
.withResolverStyle(ResolverStyle.STRICT) // Invalidates xxxx-02-30 instead of transforming it into xxxx-02-28
.parse(
s.replaceAll("(st|rd|th)""st|rd|th","") // remove useless stuff around the date
)
)
Credits
- 2 bytes in the regex thanks to Neil.
Java (OpenJDK 8), 187 + 26 = 213 bytes
import java.time.format.*;
s->DateTimeFormatter.ofPattern("uuuu/MM/dd").format(DateTimeFormatter.ofPattern("[EEEE, ][d ]MMMM [d, ]uuuu").withResolverStyle(ResolverStyle.STRICT).parse(s.replaceAll("(st|rd|th)","")))
Important note: it was shorter to also validate the day of week instead of ditching it, so that validation is included!
I haven't tried with SimpleDateFormat beyond the obvious cases which all accepted dates like 30 February. So I had to ditch it and I used Java 8's DateTimeFormatter.
Explanation
"[EEEE, ][d ]MMMM [d, ]uuuu"
This format means :
- optional day-of-week followed by comma and space
[EEEE, ](happens inSunday, ...), - followed by optional day with space
[d ], - followed by month in full letters
MMMMand space, - followed by optional day with comma and space
[d, ], - followed by year of era
uuuuto let the parser know we're in Gregorian era.
Code:
import java.time.format.*; // Required for DateTimeFormatter, *and* ResolverStyle
s->DateTimeFormatter.ofPattern("uuuu/MM/dd") // Output format
.format(
DateTimeFormatter.ofPattern("[EEEE, ][d ]MMMM [d, ]uuuu") // Input format
.withResolverStyle(ResolverStyle.STRICT) // Invalidates xxxx-02-30 instead of transforming it into xxxx-02-28
.parse(
s.replaceAll("(st|rd|th)","") // remove useless stuff around the date
)
)
Java (OpenJDK 8), 185 + 26 = 211 bytes
import java.time.format.*;
s->DateTimeFormatter.ofPattern("uuuu/MM/dd").format(DateTimeFormatter.ofPattern("[EEEE, ][d ]MMMM [d, ]uuuu").withResolverStyle(ResolverStyle.STRICT).parse(s.replaceAll("st|rd|th","")))
Important note: it was shorter to also validate the day of week instead of ditching it, so that validation is included!
I haven't tried with SimpleDateFormat beyond the obvious cases which all accepted dates like 30 February. So I had to ditch it and I used Java 8's DateTimeFormatter.
Explanation
"[EEEE, ][d ]MMMM [d, ]uuuu"
This format means :
- optional day-of-week followed by comma and space
[EEEE, ](happens inSunday, ...), - followed by optional day with space
[d ], - followed by month in full letters
MMMMand space, - followed by optional day with comma and space
[d, ], - followed by year of era
uuuuto let the parser know we're in Gregorian era.
Code:
import java.time.format.*; // Required for DateTimeFormatter, *and* ResolverStyle
s->DateTimeFormatter.ofPattern("uuuu/MM/dd") // Output format
.format(
DateTimeFormatter.ofPattern("[EEEE, ][d ]MMMM [d, ]uuuu") // Input format
.withResolverStyle(ResolverStyle.STRICT) // Invalidates xxxx-02-30 instead of transforming it into xxxx-02-28
.parse(
s.replaceAll("st|rd|th","") // remove useless stuff around the date
)
)
Credits
- 2 bytes in the regex thanks to Neil.