Skip to content

Commit 606b689

Browse files
committed
Merge branch '6.2.x'
2 parents a1f5f6a + 6978f0a commit 606b689

File tree

1 file changed

+25
-15
lines changed
  • spring-core/src/main/java/org/springframework/util/unit

1 file changed

+25
-15
lines changed

spring-core/src/main/java/org/springframework/util/unit/DataSize.java

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -138,14 +138,19 @@ public static DataSize of(long amount, DataUnit unit) {
138138
}
139139

140140
/**
141-
* Obtain a {@link DataSize} from a text string such as {@code 12MB} using
141+
* Obtain a {@link DataSize} from a text string such as {@code "5MB"} using
142142
* {@link DataUnit#BYTES} if no unit is specified.
143-
* <p>Examples:
144-
* <pre>
145-
* "12KB" -- parses as "12 kilobytes"
146-
* "5MB" -- parses as "5 megabytes"
147-
* "20" -- parses as "20 bytes"
148-
* </pre>
143+
* <h4>Examples</h4>
144+
* <table border="1">
145+
* <tr><th>Text</th><th>Parsed As</th><th>Size in Bytes</th></tr>
146+
* <tr><td>"20"</td><td>20 bytes</td><td>20</td></tr>
147+
* <tr><td>"20B"</td><td>20 bytes</td><td>20</td></tr>
148+
* <tr><td>"12KB"</td><td>12 kilobytes</td><td>12,288</td></tr>
149+
* <tr><td>"5MB"</td><td>5 megabytes</td><td>5,242,880</td></tr>
150+
* </table>
151+
* <p>Note that the terms and units used in the above examples are based on
152+
* <a href="https://en.wikipedia.org/wiki/Binary_prefix">binary prefixes</a>.
153+
* Consult the {@linkplain DataSize class-level Javadoc} for details.
149154
* @param text the text to parse
150155
* @return the parsed {@code DataSize}
151156
* @see #parse(CharSequence, DataUnit)
@@ -155,19 +160,24 @@ public static DataSize parse(CharSequence text) {
155160
}
156161

157162
/**
158-
* Obtain a {@link DataSize} from a text string such as {@code 12MB} using
163+
* Obtain a {@link DataSize} from a text string such as {@code "5MB"} using
159164
* the specified default {@link DataUnit} if no unit is specified.
160165
* <p>The string starts with a number followed optionally by a unit matching
161166
* one of the supported {@linkplain DataUnit suffixes}.
162167
* <p>If neither a unit nor a default {@code DataUnit} is specified,
163168
* {@link DataUnit#BYTES} will be inferred.
164-
* <p>Examples:
165-
* <pre>
166-
* "12KB" -- parses as "12 kilobytes"
167-
* "5MB" -- parses as "5 megabytes"
168-
* "20" -- parses as "20 kilobytes" (where the {@code defaultUnit} is {@link DataUnit#KILOBYTES})
169-
* "20" -- parses as "20 bytes" (if the {@code defaultUnit} is {@code null})
170-
* </pre>
169+
* <h4>Examples</h4>
170+
* <table border="1">
171+
* <tr><th>Text</th><th>Default Unit</th><th>Parsed As</th><th>Size in Bytes</th></tr>
172+
* <tr><td>"20"</td><td>{@code null}</td><td>20 bytes</td><td>20</td></tr>
173+
* <tr><td>"20"</td><td>{@link DataUnit#KILOBYTES KILOBYTES}</td><td>20 kilobytes</td><td>20,480</td></tr>
174+
* <tr><td>"20B"</td><td>N/A</td><td>20 bytes</td><td>20</td></tr>
175+
* <tr><td>"12KB"</td><td>N/A</td><td>12 kilobytes</td><td>12,288</td></tr>
176+
* <tr><td>"5MB"</td><td>N/A</td><td>5 megabytes</td><td>5,242,880</td></tr>
177+
* </table>
178+
* <p>Note that the terms and units used in the above examples are based on
179+
* <a href="https://en.wikipedia.org/wiki/Binary_prefix">binary prefixes</a>.
180+
* Consult the {@linkplain DataSize class-level Javadoc} for details.
171181
* @param text the text to parse
172182
* @param defaultUnit the default {@code DataUnit} to use
173183
* @return the parsed {@code DataSize}

0 commit comments

Comments
 (0)