-
Notifications
You must be signed in to change notification settings - Fork 3
kiwi.time.DateTime
Nikos Siatras edited this page Sep 29, 2022
·
18 revisions
Kiwi's DateTime object represents a specific instant in time, with millisecond precision.
It is highly recommended to initialize DateTime objects using a Kiwi's Calendar object.
| Method | Description |
|---|---|
| DateTime.setTime(millis as LongInt) | Sets this DateTime object to represent a point in time that is milliseconds after January 1, 1970 00:00:00 GMT. |
| DateTime.getTime() | Returns the number of milliseconds since January 1, 1970, 00:00:00 UTC represented by this Date object |
| DateTime.getTimeZoneOffset() | Returns the offset, in hours, between this date instance and the Coordinated Universal Time (UTC). |
| DateTime.setTimeZoneOffset(hours as Integer) | Sets the offset, in hours, between this date instance and the Coordinated Universal Time (UTC) |
| DateTime.add(timeField as Integer, amount as Integer) | Adds or subtracts the specified amount of time to the given DateTime Object. The timefield values can be DateTime.YEAR,DateTime.MONTH, DateTime.WEEK, DateTime.DAY, DateTime.HOUR, DateTime.MINUTE, DateTime.SECOND, DateTime.MILLISECOND |
| DateTime.toString() | Converts this DateTime object to a String of the form: ddd mmm yyyy hh:nn:ss. For example "Tue Jul 08 1986 18:30:25" |
The following simple examples will try to explain the use of Kiwi's DateTime object
A basic DateTime example in order to print system's current Date-Time
#include once "kiwi\kiwi.bi"
#include once "kiwi\time.bi"
' Print's system's current Date Time
Dim dt as DateTime = DateTime(System.currentTimeMillis())
print dt.toString()The following example will convert a UTC +0 Timestamp to UTC +3 timestamp.
#include once "kiwi\kiwi.bi"
#include once "kiwi\time.bi"
' The following timestamp is from Wed Sep 28 2022 06:40:39 UTC +0
Dim timeStampUTC as LongInt = 1664347239101
' Print the utcTime
Dim utcTime as DateTime = DateTime(timeStampUTC,0) ' UTC +0
print utcTime.toString()
' Convert the timeStampUTC to Athens/Greece timezone and print to console
Dim timeInAthens as DateTime = DateTime(timeStampUTC, 3)' UTC +3
print timeInAthens.toString()#include once "kiwi\kiwi.bi"
#include once "kiwi\time.bi"
' The following timestamp is from Wed Sep 28 2022 06:40:39 UTC +0
Dim timeStampUTC as LongInt = 1664347239101
' Add time to timeStampUTC
Dim utcTime as DateTime = DateTime(timeStampUTC, 0)
utcTime.add(DateTime.YEAR, 10)
utcTime.add(DateTime.MONTH, 2)
utcTime.add(DateTime.WEEK, 2)
utcTime.add(DateTime.DAY, 5)
utcTime.add(DateTime.HOUR, 4)
utcTime.add(DateTime.MINUTE, 45)
utcTime.add(DateTime.SECOND, 10)
utcTime.add(DateTime.MILLISECOND, 20)
print utcTime.toString() ' This prints Fri Dec 17 2032 11:25:49 UTC +0- MySQL/MariaDB - Coming to v1.0.2
- ArrayList
- Comparator
- HashMap - Coming to v1.0.2
- Queue