public class Golang extends Object
Constructor and Description |
---|
Golang() |
Modifier and Type | Method and Description |
---|---|
static String |
encodeDurationToMs(Duration duration)
Encodes a Java duration into the encoded golang format.
|
static Duration |
parseDuration(String duration)
Parses a Go duration string using the same rules as Go's
time.ParseDuration method.
|
public static String encodeDurationToMs(Duration duration)
duration
- the duration to encode.public static Duration parseDuration(String duration)
A Go duration string is a possibly signed sequence of decimal numbers, each with optional fraction and a unit suffix, such as "300ms", "-1.5h" or "2h45m". Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h". The unit suffix may be omitted if the duration is "0".
The internal representation is a signed long number of nanoseconds. This means the longest possible duration is approximately 290 years.
InvalidArgumentException
- if the input does not match the Go duration string syntax
or if it describes a duration longer than 2^63−1 nanoseconds.Copyright © 2024 Couchbase, Inc.. All rights reserved.