I'm trying to specify an [ISO week date][1] format in my JavaDoc @since tag, which includes a literal 'W' for the week of the year.
Currently, when I use ${currentDate:date('YYYY-w-u HH.mm.ss.SS Z')}
, it formats the date as 2024-36-4 20.02.42.06 -0400
. However, I want the format to include 'W' like this: 2024-W36-4 20.02.42.06 -0400
.
I've tried using 'W'
, "W"
, and \W
in the date format string, but they either result in an incorrect format or are interpreted incorrectly (e.g., \W
becomes \1
).
How can I escape the 'W' character so that it is treated as a literal in my date format string within the ${currentDate}
function or a similar mechanism?
JavaDoc Example:
/**
* Description of your class or method.
*
* @since 2024-W36-4 20.02.42.06 -0400
*/
public class MyClass {
// Code here
}
Any insights or alternative approaches to achieve the desired date format with the literal 'W' would be greatly appreciated. Thank you!
I am using Eclipse. [1]: https://en.m.wikipedia.org/wiki/ISO_week_date
The Eclipse code template date uses the SimpleDateFormat
pattern.
SimpleDataFormat would require quote characters around the W - so 'W'
But the code template parser does not support escaping a '
in the middle of a pattern so you can't do this with a single variable.
You can do it using two variables with the W as plain text between them:
@since ${part1:date('yyyy-')}W${part2:date('w-u HH.mm.ss.SS Z')}