@@ -141,6 +141,16 @@ public static UUID random() {
141141 * UUID generated by this method are suitable for use with the
142142 * {@code timeuuid} Cassandra type. In particular the generated UUID
143143 * includes the timestamp of its generation.
144+ * <p/>
145+ * Note that there is no way to provide your own timestamp. This is deliberate, as we feel that this does not
146+ * conform to the UUID specification, and therefore don't want to encourage it through the API.
147+ * If you want to do it anyway, use the following workaround:
148+ * <pre>
149+ * Random random = new Random();
150+ * UUID uuid = new UUID(UUIDs.startOf(userProvidedTimestamp).getMostSignificantBits(), random.nextLong());
151+ * </pre>
152+ * If you simply need to perform a range query on a {@code timeuuid} column, use the "fake" UUID generated by
153+ * {@link #startOf(long)} and {@link #endOf(long)}.
144154 *
145155 * @return a new time-based UUID.
146156 */
@@ -157,14 +167,16 @@ public static UUID timeBased() {
157167 * <p/>
158168 * The UUID created by this method <b>are not unique</b> and as such are
159169 * <b>not</b> suitable for anything else than querying a specific time
160- * range. In particular, you should not insert such UUID.
170+ * range. In particular, you should not insert such UUID. "True" UUID from
171+ * user-provided timestamps are not supported (see {@link #timeBased()}
172+ * for more explanations).
161173 * <p/>
162174 * Also, the timestamp to provide as parameter must be a unix timestamp (as
163175 * returned by {@link System#currentTimeMillis} or {@link java.util.Date#getTime}),
164- * not a UUID 100-nanoseconds intervals since 15 October 1582. In other
176+ * not a UUID 100-nanoseconds interval since 15 October 1582. In other
165177 * words, given a UUID {@code uuid}, you should never do
166178 * {@code startOf(uuid.timestamp())} but rather
167- * {@code startOf(unixTimestamp(uuid.timestamp() ))}.
179+ * {@code startOf(unixTimestamp(uuid))}.
168180 * <p/>
169181 * Lastly, please note that Cassandra's timeuuid sorting is not compatible
170182 * with {@link UUID#compareTo} and hence the UUID created by this method
@@ -182,23 +194,7 @@ public static UUID startOf(long timestamp) {
182194 * Creates a "fake" time-based UUID that sorts as the biggest possible
183195 * version 1 UUID generated at the provided timestamp.
184196 * <p/>
185- * Such created UUID are useful in queries to select a time range of a
186- * {@code timeuuid} column.
187- * <p/>
188- * The UUID created by this method <b>are not unique</b> and as such are
189- * <b>not</b> suitable for anything else than querying a specific time
190- * range. In particular, you should not insert such UUID.
191- * <p/>
192- * Also, the timestamp to provide as parameter must be a unix timestamp (as
193- * returned by {@link System#currentTimeMillis} or {@link java.util.Date#getTime}),
194- * not a UUID 100-nanoseconds intervals since 15 October 1582. In other
195- * words, given a UUID {@code uuid}, you should never do
196- * {@code startOf(uuid.timestamp())} but rather
197- * {@code startOf(unixTimestamp(uuid.timestamp()))}.
198- * <p/>
199- * Lastly, please note that Cassandra's timeuuid sorting is not compatible
200- * with {@link UUID#compareTo} and hence the UUID created by this method
201- * are not necessarily upper bound for that latter method.
197+ * See {@link #startOf(long)} for explanations about the intended usage of such UUID.
202198 *
203199 * @param timestamp the unix timestamp for which the created UUID must be an
204200 * upper bound.
0 commit comments