Show / Hide Table of Contents

Class Duration

Represents a length of time.

Inheritance
System.Object
Duration
Namespace: Amazon.CDK
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public class Duration : DeputyBase
Syntax (vb)
Public Class Duration
    Inherits DeputyBase
Remarks

The amount can be specified either as a literal value (e.g: 10) which cannot be negative, or as an unresolved number token.

When the amount is passed as a token, unit conversion is not possible.

ExampleMetadata: infused

Examples
// Example automatically generated from non-compiling source. May contain errors.
using Amazon.CDK.AWS.CloudWatch;


var table = new Table(this, "Table", new TableProps {
    PartitionKey = new Attribute { Name = "id", Type = AttributeType.STRING }
});

var metric = table.MetricThrottledRequestsForOperations(new OperationsMetricOptions {
    Operations = new [] { Operation.PUT_ITEM },
    Period = Duration.Minutes(1)
});

new Alarm(stack, "Alarm", new AlarmProps {
    Metric = metric,
    EvaluationPeriods = 1,
    Threshold = 1
});

Synopsis

Constructors

Duration(ByRefValue)

Used by jsii to construct an instance of this class from a Javascript-owned object reference

Duration(DeputyBase.DeputyProps)

Used by jsii to construct an instance of this class from DeputyProps

Methods

Days(Double)

Create a Duration representing an amount of days.

FormatTokenToNumber()

Returns stringified number of duration.

Hours(Double)

Create a Duration representing an amount of hours.

IsUnresolved()

Checks if duration is a token or a resolvable object.

Millis(Double)

Create a Duration representing an amount of milliseconds.

Minus(Duration)

Substract two Durations together.

Minutes(Double)

Create a Duration representing an amount of minutes.

Parse(String)

Parse a period formatted according to the ISO 8601 standard.

Plus(Duration)

Add two Durations together.

Seconds(Double)

Create a Duration representing an amount of seconds.

ToDays(ITimeConversionOptions)

Return the total number of days in this Duration.

ToHours(ITimeConversionOptions)

Return the total number of hours in this Duration.

ToHumanString()

Turn this duration into a human-readable string.

ToIsoString()

Return an ISO 8601 representation of this period.

ToMilliseconds(ITimeConversionOptions)

Return the total number of milliseconds in this Duration.

ToMinutes(ITimeConversionOptions)

Return the total number of minutes in this Duration.

ToSeconds(ITimeConversionOptions)

Return the total number of seconds in this Duration.

ToString()

Returns a string representation of this Duration.

UnitLabel()

Returns unit of the duration.

Constructors

Duration(ByRefValue)

Used by jsii to construct an instance of this class from a Javascript-owned object reference

protected Duration(ByRefValue reference)
Parameters
reference Amazon.JSII.Runtime.Deputy.ByRefValue

The Javascript-owned object reference

Duration(DeputyBase.DeputyProps)

Used by jsii to construct an instance of this class from DeputyProps

protected Duration(DeputyBase.DeputyProps props)
Parameters
props Amazon.JSII.Runtime.Deputy.DeputyBase.DeputyProps

The deputy props

Methods

Days(Double)

Create a Duration representing an amount of days.

public static Duration Days(double amount)
Parameters
amount System.Double

the amount of Days the Duration will represent.

Returns

Duration

a new Duration representing amount Days.

FormatTokenToNumber()

Returns stringified number of duration.

public virtual string FormatTokenToNumber()
Returns

System.String

Hours(Double)

Create a Duration representing an amount of hours.

public static Duration Hours(double amount)
Parameters
amount System.Double

the amount of Hours the Duration will represent.

Returns

Duration

a new Duration representing amount Hours.

IsUnresolved()

Checks if duration is a token or a resolvable object.

public virtual bool IsUnresolved()
Returns

System.Boolean

Millis(Double)

Create a Duration representing an amount of milliseconds.

public static Duration Millis(double amount)
Parameters
amount System.Double

the amount of Milliseconds the Duration will represent.

Returns

Duration

a new Duration representing amount ms.

Minus(Duration)

Substract two Durations together.

public virtual Duration Minus(Duration rhs)
Parameters
rhs Duration
Returns

Duration

Minutes(Double)

Create a Duration representing an amount of minutes.

public static Duration Minutes(double amount)
Parameters
amount System.Double

the amount of Minutes the Duration will represent.

Returns

Duration

a new Duration representing amount Minutes.

Parse(String)

Parse a period formatted according to the ISO 8601 standard.

public static Duration Parse(string duration)
Parameters
duration System.String

an ISO-formtted duration to be parsed.

Returns

Duration

the parsed Duration.

Remarks

See: https://www.iso.org/standard/70907.html

Plus(Duration)

Add two Durations together.

public virtual Duration Plus(Duration rhs)
Parameters
rhs Duration
Returns

Duration

Seconds(Double)

Create a Duration representing an amount of seconds.

public static Duration Seconds(double amount)
Parameters
amount System.Double

the amount of Seconds the Duration will represent.

Returns

Duration

a new Duration representing amount Seconds.

ToDays(ITimeConversionOptions)

Return the total number of days in this Duration.

public virtual double ToDays(ITimeConversionOptions opts = null)
Parameters
opts ITimeConversionOptions
Returns

System.Double

the value of this Duration expressed in Days.

ToHours(ITimeConversionOptions)

Return the total number of hours in this Duration.

public virtual double ToHours(ITimeConversionOptions opts = null)
Parameters
opts ITimeConversionOptions
Returns

System.Double

the value of this Duration expressed in Hours.

ToHumanString()

Turn this duration into a human-readable string.

public virtual string ToHumanString()
Returns

System.String

ToIsoString()

Return an ISO 8601 representation of this period.

public virtual string ToIsoString()
Returns

System.String

a string starting with 'P' describing the period

Remarks

See: https://www.iso.org/standard/70907.html

ToMilliseconds(ITimeConversionOptions)

Return the total number of milliseconds in this Duration.

public virtual double ToMilliseconds(ITimeConversionOptions opts = null)
Parameters
opts ITimeConversionOptions
Returns

System.Double

the value of this Duration expressed in Milliseconds.

ToMinutes(ITimeConversionOptions)

Return the total number of minutes in this Duration.

public virtual double ToMinutes(ITimeConversionOptions opts = null)
Parameters
opts ITimeConversionOptions
Returns

System.Double

the value of this Duration expressed in Minutes.

ToSeconds(ITimeConversionOptions)

Return the total number of seconds in this Duration.

public virtual double ToSeconds(ITimeConversionOptions opts = null)
Parameters
opts ITimeConversionOptions
Returns

System.Double

the value of this Duration expressed in Seconds.

ToString()

Returns a string representation of this Duration.

public override string ToString()
Returns

System.String

Remarks

This is is never the right function to use when you want to use the Duration object in a template. Use toSeconds(), toMinutes(), toDays(), etc. instead.

UnitLabel()

Returns unit of the duration.

public virtual string UnitLabel()
Returns

System.String

Back to top Generated by DocFX