Study guide
6.2 DateTime Formatting, Timezone Conversions & TimeSpan Calculations
UiPath Automation Developer Professional UiPath-ADPv1
Track your progress as you read
Finished sections get a check mark.
1 Chapter 1: Exam Overview & Blueprint Map
1.1 About the UiPath-ADPv1 Exam: Format, Fees & Policies 1.2 The Exam Topics Mapped to This Guide & a Study Plan
2 Chapter 2: REFramework Architecture & State Dynamics
2.1 State Machine Architecture & The Four Core States 2.2 Configuration Management: Settings, Constants, and Assets 2.3 Transaction Types & The Dispatcher vs. Performer Architecture 2.4 Adapting REFramework: Tabular Data, Collections & Linear Processes
3 Chapter 3: REFramework Exception Handling & Recovery
3.1 BusinessRuleException vs. System.Exception Handling Patterns 3.2 Retry Mechanisms: Queue Retries vs. REFramework MaxRetryNumber 3.3 Consecutive System Exceptions & Graceful Process Termination
4 Chapter 4: State Machines, Custom Log Fields & REFramework Testing
4.1 Building State Machine Projects in Studio 4.2 Logging Levels, Robot Logs & Custom Log Fields in REFramework 4.3 Testing a REFramework Project With and Without Orchestrator Queues
5 Chapter 5: LINQ Queries & DataTable Operations
5.1 LINQ Essentials for Collections & Filtering 5.2 Advanced DataTable Querying with LINQ 5.3 In-Memory DataTable Transformations & Column Operations
6 Chapter 6: Regex, DateTime, JSON & Invoke Activities
6.1 Regular Expressions & Text Parsing for Automation 6.2 DateTime Formatting, Timezone Conversions & TimeSpan Calculations 6.3 JSON Parsing, JSONPath & Serialization with Newtonsoft.Json 6.4 Invoke Method & Invoke Code Activities 6.5 Data Referencing in Invokes: DataTable, List & Dictionary Arguments
7 Chapter 7: Modern UI Automation & Unified Targeting
7.1 Modern Design Experience & The Unified Target Concept 7.2 Anchors, Relative Elements & UI Automation Activities 7.3 Dynamic Selectors, Variables & Wildcards in Selectors
8 Chapter 8: Object Repository, Computer Vision & Remote Runtime
8.1 Object Repository & UI Descriptor Libraries 8.2 AI Computer Vision for Unattended & Remote Interfaces 8.3 Automation in Virtual Environments & UiPath Remote Runtime
9 Chapter 9: Advanced UI Automation: Browser Modes, Agentic UI & macOS
9.1 Browser Automation with the WebDriver Protocol 9.2 Agentic UI Automation: ScreenPlay, Semantic Activities & Healing Agent 9.3 macOS Automation: Native Apps, Office Apps & AppleScript
10 Chapter 10: Advanced Control Flow & Exception Architecture
10.1 Flowcharts, Sequences & Parallel Control Flow Patterns 10.2 Global Exception Handler Architecture & ErrorAction Directives 10.3 TryCatch, Retry Scope & Custom Exception Architectures
11 Chapter 11: Orchestrator Queues & Transaction Management
11.1 Queue Architecture, SpecificContent & Transaction Lifecycles 11.2 Queue Items SLA, Postpone, Deadlines & Priority Scheduling 11.3 Bulk Operations, Transaction Status Updates & Queue Triggers
12 Chapter 12: Orchestrator Tenant & Folder Entities
12.1 Asset Types, Per-Robot Assets & External Credential Stores 12.2 Modern Folder Hierarchy, User/Robot Assignment & Permissions 12.3 Storage Buckets, Webhooks & Environment Promotion 12.4 Orchestrator Tags: Labels, Properties & Governance
13 Chapter 13: Unattended Execution, API Triggers & Cloud Robots
13.1 Unattended Job Execution: Folders, Priorities, Background vs. Foreground & Runtimes 13.2 API Triggers: Starting Jobs from External Systems over HTTP 13.3 Serverless and Cloud VM Robots: Cloud-Hosted Execution Options
14 Chapter 14: Monitoring, Recording & Solutions Management
14.1 Orchestrator Monitoring, Trigger Alerts & Job Health 14.2 Job and Transaction Recording: Troubleshooting Faulted Unattended Jobs 14.3 Solutions Management: Packaging and Deploying Automations with Their Resources
15 Chapter 15: Debugging, Remote Debugging & Profiling
15.1 Studio Debugging Tools: Breakpoints, Panels & Execution Control 15.2 Remote Debugging: Remote Machine and Unattended Robot Connections 15.3 Profile Execution: Finding Performance Bottlenecks in Studio
16 Chapter 16: RPA Testing & Test Suite
16.1 UiPath Test Suite Overview, Test Cases & Given-When-Then Structure 16.2 Data-Driven Testing, Test Verification Activities & Mock Activities 16.3 CI/CD Pipelines with uipcli & Test Manager Traceability
17 Chapter 17: Long-Running Workflows, Action Center & Apps
17.1 Long-Running Workflows: Persistence, Suspend and Resume 17.2 Action Center & Human-in-the-Loop Orchestration 17.3 UiPath Apps: Action Apps, Automations & Integration Service
18 Chapter 18: Trigger-Based Attended Automation & Callouts
18.1 Trigger-Based Attended Automation: Forms, Triggers & Global Variables 18.2 Running Local Triggers & the Event Inspection Tool 18.3 Callouts & Forms for Attended Guidance
19 Chapter 19: UiPath Assistant & Robot Sessions
19.1 UiPath Assistant: Automations, Reminders, Widgets & Configuration 19.2 Robot Session (Picture in Picture): Child Session vs. Virtual Desktop
20 Chapter 20: Autopilot for Developers & Autopilot for Everyone
20.1 Autopilot for Developers: AI Assistance in Studio and Studio Web 20.2 Autopilot for Everyone: Chat, Automations & Clipboard AI
21 Chapter 21: API Automation & Integration Service
21.1 Integration Service: Connectors, Connections & Connector Activities 21.2 API Workflows in Studio Web 21.3 HTTP Requests: Web APIs, the Orchestrator API & Connector Requests 21.4 Connector Builder: Custom Integration Service Connectors 21.5 Integration Service Event Triggers: Connected and Disconnected 21.6 GenAI Activities: Generative AI Inside Workflows
22 Chapter 22: Data Service, Context Grounding & Coded Workflows
22.1 Data Fabric (Data Service) Entities: Modeling Business Data 22.2 Data Fabric Activities and the Platform Connector 22.3 Context Grounding: Retrieval-Augmented Generation with Company Data 22.4 Coded Automations: Structure, Arguments & Invoking Workflows 22.5 Coded Automation Services: Orchestrator, UI Automation, Microsoft 365 & Custom Services
23 Chapter 23: Integrated Scenario Practice
23.1 Integrated Scenario Practice: Designing an End-to-End Solution
6.2 DateTime Formatting, Timezone Conversions & TimeSpan Calculations
Key Takeaways Explain This Topic AI
DateTime.ParseExact and TryParseExact with CultureInfo.InvariantCulture parse a known format the same way on every robot, whatever its regional settings.
Format specifiers are case-sensitive: MM is month and mm is minutes, HH is 24-hour and hh is 12-hour (pair it with tt), and fff is milliseconds.
Subtracting two DateTime values gives a TimeSpan; use TotalMinutes or TotalHours for thresholds, because Minutes and Hours return only one component.
Orchestrator stores timestamps in UTC and displays them in the configured time zone; each time trigger has its own time zone, and Add Queue Item accepts relative Deadline and Postpone expressions such as DateTime.Now.AddHours(2).
Business-day calculations loop day by day and skip weekends and a holiday list, often stored in an asset or data table.
Last updated: September 2026
6.2 DateTime Formatting, Timezone Conversions & TimeSpan Calculations
In enterprise automation workflows, temporal data drives critical business logic: calculating payment due dates, determining service-level agreement (SLA) deadlines, polling file directories for batch windows, and correlating transaction timestamps in Orchestrator logs. However, because unattended robots execute across geographically distributed virtual machines, cloud containers, and enterprise servers with differing regional locale settings, date and time handling is one of the most frequent causes of intermittent production failures.
To build robust, globally deployable automations, developers must master the System.DateTime , System.TimeSpan , and System.TimeZoneInfo types within the .NET runtime. This section provides an architectural deep dive into culture-invariant parsing, exact format masks, temporal arithmetic, duration benchmarking, UTC synchronization with Orchestrator, and business calendar algorithms.
1. Architectural Overview: System.DateTime & Culture-Dependent Parsing Pitfalls
In the .NET runtime, System.DateTime is an immutable value type representing a date and time as a 64-bit integer representing ticks (where 1 tick = 100 nanoseconds) elapsed since 12:00:00 AM on January 1, 0001 in the Gregorian calendar.
The Pitfall of DateTime.Parse() and Regional Settings
When developers use DateTime.Parse(dateString) or Convert.ToDateTime(dateString) , the .NET runtime relies on CultureInfo.CurrentCulture —the regional settings of the Windows user account running the UiPath Robot service:
On an American server ( en-US ), "05/06/2026" parses as May 6, 2026 .
On a British or Australian server ( en-GB ), the exact same string parses as June 5, 2026 .
On a system expecting YYYY-MM-DD , passing "05/06/2026" throws an unhandled System.FormatException .
This introduces catastrophic data corruption in multi-tenant or cloud robot fleets, where a robot running in Frankfurt processes an invoice generated in New York and swaps the month and day.
Exact Parsing with DateTime.ParseExact
To enforce deterministic parsing regardless of robot OS culture, developers must use DateTime.ParseExact() with System.Globalization.CultureInfo.InvariantCulture : ' VB.NET: Deterministic parsing using CultureInfo.InvariantCulture
Dim rawDateStr As String = "2026-09-29 14:35:00"
Dim invoiceDate As DateTime = DateTime.ParseExact(rawDateStr, "yyyy-MM-dd HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture) // C#: Deterministic parsing using CultureInfo.InvariantCulture
string rawDateStr = "2026-09-29 14:35:00";
DateTime invoiceDate = DateTime.ParseExact(rawDateStr, "yyyy-MM-dd HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture);
Defensive Non-Throwing Parsing with DateTime.TryParseExact
In unattended workflows processing external documents, dates may be malformed or blank. While DateTime.ParseExact throws a fatal FormatException on mismatched input, DateTime.TryParseExact returns a Boolean indicating success and outputs the parsed date via an Out argument without raising an exception: ' VB.NET: Defensive TryParseExact implementation in an Assign or If activity
- Dim rawInput As String = "15/10/2026"
- Dim parsedDate As DateTime
- Dim isValidDate As Boolean = DateTime.TryParseExact(rawInput, _
- "dd/MM/yyyy", _
- System.Globalization.CultureInfo.InvariantCulture, _
- System.Globalization.DateTimeStyles.None, _
- parsedDate)
- If isValidDate Then
- ' Proceed with valid date
- Else
Throw New BusinessRuleException("The transaction date '" & rawInput & "' does not conform to the expected dd/MM/yyyy format.")
- End If
- Handling Multiple Acceptable Formats
When an upstream source formats dates inconsistently (e.g., legacy systems providing either yyyy-MM-dd or MM/dd/yyyy ), pass an array of acceptable format strings: ' VB.NET: Parsing across multiple candidate date formats
- Dim acceptableFormats As String() = {"yyyy-MM-dd", "MM/dd/yyyy", "dd/MM/yyyy", "yyyyMMdd"}
- Dim success As Boolean = DateTime.TryParseExact(rawDateStr, _
- acceptableFormats, _
- System.Globalization.CultureInfo.InvariantCulture, _
- System.Globalization.DateTimeStyles.None, _
- parsedDate)
- 2. Comprehensive Custom & Standard DateTime Format Specifiers
When parsing strings into DateTime objects or formatting DateTime instances for presentation, specifiers are strictly case-sensitive. Confusing letter casing is a primary trap on professional certification exams.
Specifier Definition Example ( 2026-09-08 07:05:09.045 ) Common Pitfall / Architectural Note
yyyy 4-digit year "2026" Use yyyy instead of yy to prevent 20th vs 21st century ambiguity.
yy 2-digit year "26" Truncates century; prone to century rollover misinterpretation.
MM 2-digit month (01–12) "09" UPPERCASE MM . Lowercase mm is minutes!
M 1 or 2-digit month (1–12) "9" No leading zero for single-digit months.
MMM Abbreviated month name "Sep" Culture-dependent unless InvariantCulture is specified.
MMMM Full month name "September" Culture-dependent unless InvariantCulture is specified.
dd 2-digit day of month (01–31) "08" Zero-padded day of month.
d 1 or 2-digit day of month (1–31) "8" Unpadded day of month.
ddd Abbreviated day of week "Tue" e.g., Mon, Tue, Wed.
dddd Full day of week "Tuesday" e.g., Monday, Tuesday.
HH 24-hour hour (00–23) "07" (or "19" for 7 PM) UPPERCASE HH . Standard military/enterprise time.
hh 12-hour hour (01–12) "07" LOWERCASE hh . Must be paired with tt (AM/PM) to distinguish morning from evening!
mm Minutes (00–59) "05" LOWERCASE mm . Uppercase MM is month!
ss Seconds (00–59) "09" Zero-padded seconds.
fff Milliseconds (3 digits) "045" Fractional seconds to 3 decimal places.
tt AM/PM designator "AM" (or "PM" ) Required when using 12-hour format ( hh ).
K Timezone representation "-04:00" , "Z" , or empty Serializes timezone information for ISO 8601 strings. ' Formatting example: Generating an ISO 8601 timestamp for a REST API payload
- Dim isoTimestamp As String = DateTime.UtcNow.ToString("yyyy-MM-dd'T'HH:mm:ss.fff'Z'")
- ' Output: "2026-09-29T14:35:00.045Z"
- 3. Date Arithmetic & Manipulation Methods
DateTime objects are immutable. Calling an arithmetic method does not alter the original variable; it returns a new DateTime instance.
Core Arithmetic Methods
.AddDays(Double) : Adds or subtracts days. Negative values subtract days (e.g., now.AddDays(-7) for one week ago). Fractional values represent partial days (e.g., 0.5 adds 12 hours).
.AddMonths(Int32) : Adds months, intelligently adjusting for varying month lengths (e.g., adding 1 month to January 31 yields February 28 or 29).
.AddYears(Int32) : Adds years, handling leap year adjustments.
.AddHours(Double) , .AddMinutes(Double) , .AddSeconds(Double) : Adjusts specific time increments.
Calculating Fiscal and Month Boundaries
Common reporting automations require calculating the first or last day of a period: ' VB.NET: First day of current month
Dim firstDayCurrentMonth As New DateTime(DateTime.Now.Year, DateTime.Now.Month, 1)
' VB.NET: Last day of current month (First day of next month minus one day)
Dim lastDayCurrentMonth As DateTime = (New DateTime(DateTime.Now.Year, DateTime.Now.Month, 1)).AddMonths(1).AddDays(-1)
- ' VB.NET: First day of previous month
- Dim firstDayPrevMonth As DateTime = (New DateTime(DateTime.Now.Year, DateTime.Now.Month, 1)).AddMonths(-1)
- 4. System.TimeSpan Durations, Benchmarking & Timeouts
While DateTime represents a discrete moment on the timeline, System.TimeSpan represents an elapsed duration or time interval.
Instantiating TimeSpan
Developers instantiate TimeSpan objects using static factory methods:
- TimeSpan.FromDays(2.5)
- TimeSpan.FromHours(1.5)
- TimeSpan.FromMinutes(30)
- TimeSpan.FromSeconds(45)
- TimeSpan.FromMilliseconds(500)
- Calculating Duration Between Two Dates
- Subtracting one DateTime from another yields a TimeSpan : ' VB.NET: Measuring transaction execution duration
- Dim startTime As DateTime = DateTime.Now
' ... Execute transactional business logic ...
- Dim endTime As DateTime = DateTime.Now
- Dim executionTime As TimeSpan = endTime.Subtract(startTime)
- ' Or: Dim executionTime As TimeSpan = endTime - startTime
- The Critical Architectural Trap: Total Properties vs. Component Properties
Understanding the distinction between unit component properties and total cumulative properties is vital for SLA logic:
Property Return Type Definition & Architectural Behavior
Hours Int32 Represents only the hour component (0 to 23) of the interval. For an interval of 26 hours, Hours returns 2 !
TotalHours Double Represents the entire elapsed duration expressed in hours, including fractional parts. For 26 hours and 30 minutes, returns 26.5 .
Minutes Int32 Represents only the minute component (-59 to 59). For an interval of 75 minutes, returns 15 .
TotalMinutes Double Represents the complete elapsed duration expressed in minutes. For 75 minutes, returns 75.0 .
Seconds Int32 Component seconds (0 to 59).
TotalSeconds Double Total elapsed duration in seconds. For 2 minutes and 15 seconds, returns 135.0 .
Caution
If checking whether a transaction exceeded an SLA of 60 minutes, evaluating executionDuration.Minutes > 60 will never evaluate to True because Minutes caps at 59! Always evaluate executionDuration.TotalMinutes > 60.0 .
5. Time Zones: Orchestrator, Triggers & Robots
Robots, Orchestrator, and users may all be in different time zones, so it matters which clock a value refers to:
Orchestrator storage and display. Orchestrator stores timestamps such as job start times and queue item creation times in UTC, and shows them in the time zone configured for the tenant or user.
Time triggers. Each time trigger has its own Timezone setting, so a trigger set to 08:00 Eastern Time runs at 08:00 Eastern regardless of where the robot sits.
Queue item dates. On Add Queue Item , the Deadline and Postpone properties accept relative expressions. Orchestrator's queue documentation gives examples such as DateTime.Now.AddHours(2) and DateTime.Now.AddDays(10) , and also accepts an exact US-format date such as 10/15/2019 07:40:00 . On the retrieved QueueItem object, the same values appear as DueDate and DeferDate .
Robot machines. DateTime.Now uses the robot machine's local time zone. If Dispatcher and Performer robots run in different regions, agree on one convention, such as storing UTC in SpecificContent and converting only for display.
The risky values are strings and dates of kind Unspecified , for example a date parsed from a spreadsheet with no zone information. Convert them explicitly with TimeZoneInfo before comparing them with DateTime.Now or DateTime.UtcNow .
Converting Between UTC and Local Time
The System.TimeZoneInfo class manages timezone conversions and automatically accounts for Daylight Saving Time (DST) transitions. ' VB.NET: Converting a local business deadline to UTC before storing it in SpecificContent
- Dim localDeadline As DateTime = DateTime.Now.AddHours(4)
- Dim utcDeadline As DateTime = TimeZoneInfo.ConvertTimeToUtc(localDeadline)
' Store the value in the item data, for example ItemInformation("DeadlineUtc") = utcDeadline ' VB.NET: Converting UTC Queue Item Creation Time to Specific Regional Timezone
- ' Useful for customer-facing notification emails
- Dim queueItemUtc As DateTime = transactionItem.SpecificContent("CreatedAtUtc")
- Dim easternZone As TimeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time")
- Dim localEasternTime As DateTime = TimeZoneInfo.ConvertTimeFromUtc(queueItemUtc, easternZone)
Console.WriteLine("Transaction initiated at Eastern Time: " & localEasternTime.ToString("yyyy-MM-dd HH:mm:ss")) // C#: TimeZone conversion by system timezone ID
- DateTime utcTime = DateTime.UtcNow;
- DateTime tokyoTime = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(utcTime, "UTC", "Tokyo Standard Time");
- 6. Business Day & Holiday Calculation Architecture
Enterprise automations frequently require scheduling transactions based on business days (e.g., "process invoice on the 3rd business day following receipt" or "set queue item deadline 48 business hours out, excluding weekends and national holidays").
The Business Day Algorithm
A resilient business day calculation requires:
Identifying weekend days using dateTime.DayOfWeek ( DayOfWeek.Saturday or DayOfWeek.Sunday ).
Maintaining an audited collection of bank/corporate holidays (stored in an Orchestrator Asset, database table, or JSON configuration).
Utilizing a HashSet(Of DateTime) for high-performance O(1) holiday membership lookups.
Incrementing or decrementing in a procedural while-loop until the target number of business days is reached. ' VB.NET: Add N Business Days excluding weekends and corporate holidays
- Dim currentDate As DateTime = DateTime.Today
- Dim businessDaysToAdd As Integer = 5
- Dim holidays As New HashSet(Of DateTime) From {
- New DateTime(2026, 1, 1), ' New Year's Day
- New DateTime(2026, 7, 4), ' Independence Day
- New DateTime(2026, 12, 25) ' Christmas Day
- }
- Dim addedDays As Integer = 0
- While addedDays < businessDaysToAdd
- currentDate = currentDate.AddDays(1)
' Check if current date is Saturday, Sunday, or Holiday
Dim isWeekend As Boolean = (currentDate.DayOfWeek = DayOfWeek.Saturday OrElse currentDate.DayOfWeek = DayOfWeek.Sunday)
Dim isHoliday As Boolean = holidays.Contains(currentDate.Date)
- If Not isWeekend AndAlso Not isHoliday Then
- addedDays += 1
- End If
- End While
- Dim targetDueDate As DateTime = currentDate
- ' targetDueDate is now guaranteed to be 5 business days in the future // C#: Add N Business Days
- DateTime currentDate = DateTime.Today;
- int businessDaysToAdd = 5;
- HashSet<DateTime> holidays = new HashSet<DateTime> {
- new DateTime(2026, 1, 1),
- new DateTime(2026, 7, 4),
- new DateTime(2026, 12, 25)
- };
- int addedDays = 0;
- while (addedDays < businessDaysToAdd) {
- currentDate = currentDate.AddDays(1);
- bool isWeekend = currentDate.DayOfWeek == DayOfWeek.Saturday || currentDate.DayOfWeek == DayOfWeek.Sunday;
- bool isHoliday = holidays.Contains(currentDate.Date);
- if (!isWeekend && !isHoliday) {
- addedDays++;
- }
- }