HADOOP-17585. Correct timestamp format in the docs for the touch command. Contributed by Stephen O'Donnell.

This commit is contained in:
He Xiaoqiao 2021-03-14 18:09:50 +08:00
parent 970455c917
commit b1dc6c40a0
No known key found for this signature in database
GPG Key ID: A80CC124E9A0FA63
3 changed files with 13 additions and 11 deletions

View File

@ -102,8 +102,8 @@ public static class Touch extends TouchCommands {
public static final String NAME = "touch"; public static final String NAME = "touch";
public static final String USAGE = "[-" + OPTION_CHANGE_ONLY_ACCESS_TIME public static final String USAGE = "[-" + OPTION_CHANGE_ONLY_ACCESS_TIME
+ "] [-" + OPTION_CHANGE_ONLY_MODIFICATION_TIME + "] [-" + "] [-" + OPTION_CHANGE_ONLY_MODIFICATION_TIME + "] [-"
+ OPTION_USE_TIMESTAMP + " TIMESTAMP ] [-" + OPTION_DO_NOT_CREATE_FILE + OPTION_USE_TIMESTAMP + " TIMESTAMP (yyyyMMdd:HHmmss) ] "
+ "] <path> ..."; + "[-" + OPTION_DO_NOT_CREATE_FILE + "] <path> ...";
public static final String DESCRIPTION = public static final String DESCRIPTION =
"Updates the access and modification times of the file specified by the" "Updates the access and modification times of the file specified by the"
+ " <path> to the current time. If the file does not exist, then a zero" + " <path> to the current time. If the file does not exist, then a zero"
@ -114,7 +114,8 @@ public static class Touch extends TouchCommands {
+ OPTION_CHANGE_ONLY_MODIFICATION_TIME + OPTION_CHANGE_ONLY_MODIFICATION_TIME
+ " Change only the modification time \n" + "-" + " Change only the modification time \n" + "-"
+ OPTION_USE_TIMESTAMP + " TIMESTAMP" + OPTION_USE_TIMESTAMP + " TIMESTAMP"
+ " Use specified timestamp (in format yyyyMMddHHmmss) instead of current time \n" + " Use specified timestamp instead of current time\n"
+ " TIMESTAMP format yyyyMMdd:HHmmss\n"
+ "-" + OPTION_DO_NOT_CREATE_FILE + " Do not create any files"; + "-" + OPTION_DO_NOT_CREATE_FILE + " Do not create any files";
private boolean changeModTime = false; private boolean changeModTime = false;
@ -183,7 +184,8 @@ private void updateTime(PathData item) throws IOException {
time = dateFormat.parse(timestamp).getTime(); time = dateFormat.parse(timestamp).getTime();
} catch (ParseException e) { } catch (ParseException e) {
throw new IllegalArgumentException( throw new IllegalArgumentException(
"Unable to parse the specified timestamp " + timestamp, e); "Unable to parse the specified timestamp "+ timestamp
+ ". The expected format is " + dateFormat.toPattern(), e);
} }
} }
if (changeModTime ^ changeAccessTime) { if (changeModTime ^ changeAccessTime) {

View File

@ -760,7 +760,7 @@ timestamp of that URI.
* Use -a option to change only the access time * Use -a option to change only the access time
* Use -m option to change only the modification time * Use -m option to change only the modification time
* Use -t option to specify timestamp (in format yyyyMMddHHmmss) instead of current time * Use -t option to specify timestamp (in format yyyyMMdd:HHmmss) instead of current time
* Use -c option to not create file if it does not exist * Use -c option to not create file if it does not exist
The timestamp format is as follows The timestamp format is as follows
@ -770,13 +770,13 @@ The timestamp format is as follows
* HH Two digit hour of the day using 24 hour notation (e.g. 23 stands for 11 pm, 11 stands for 11 am) * HH Two digit hour of the day using 24 hour notation (e.g. 23 stands for 11 pm, 11 stands for 11 am)
* mm Two digit minutes of the hour * mm Two digit minutes of the hour
* ss Two digit seconds of the minute * ss Two digit seconds of the minute
e.g. 20180809230000 represents August 9th 2018, 11pm e.g. 20180809:230000 represents August 9th 2018, 11pm
Example: Example:
* `hadoop fs -touch pathname` * `hadoop fs -touch pathname`
* `hadoop fs -touch -m -t 20180809230000 pathname` * `hadoop fs -touch -m -t 20180809:230000 pathname`
* `hadoop fs -touch -t 20180809230000 pathname` * `hadoop fs -touch -t 20180809:230000 pathname`
* `hadoop fs -touch -a pathname` * `hadoop fs -touch -a pathname`
Exit Code: Returns 0 on success and -1 on error. Exit Code: Returns 0 on success and -1 on error.

View File

@ -819,7 +819,7 @@
<comparators> <comparators>
<comparator> <comparator>
<type>RegexpComparator</type> <type>RegexpComparator</type>
<expected-output>^-touch \[-a\] \[-m\] \[-t TIMESTAMP \] \[-c\] &lt;path&gt; \.\.\. :( )*</expected-output> <expected-output>^-touch \[-a\] \[-m\] \[-t TIMESTAMP \(yyyyMMdd\:HHmmss\) \] \[-c\] &lt;path&gt; \.\.\. :( )*</expected-output>
</comparator> </comparator>
<comparator> <comparator>
<type>RegexpComparator</type> <type>RegexpComparator</type>
@ -847,11 +847,11 @@
</comparator> </comparator>
<comparator> <comparator>
<type>RegexpComparator</type> <type>RegexpComparator</type>
<expected-output>^\s*-t\s+TIMESTAMP\s+Use specified timestamp \(in format yyyyMMddHHmmss\) instead of</expected-output> <expected-output>^\s*-t\s+TIMESTAMP\s+Use specified timestamp instead of current time( )*</expected-output>
</comparator> </comparator>
<comparator> <comparator>
<type>RegexpComparator</type> <type>RegexpComparator</type>
<expected-output>^\s*current time( )*</expected-output> <expected-output>^\s*TIMESTAMP format yyyyMMdd\:HHmmss</expected-output>
</comparator> </comparator>
<comparator> <comparator>
<type>RegexpComparator</type> <type>RegexpComparator</type>