Skip to content

Commit

Permalink
Add ZonedDateTime for Account
Browse files Browse the repository at this point in the history
  • Loading branch information
shivam1608 committed Jun 20, 2024
1 parent 6d0f78c commit 0078e33
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/main/java/me/shivzee/util/Account.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
package me.shivzee.util;

import me.shivzee.exceptions.DateTimeParserException;

import java.time.ZonedDateTime;

import static me.shivzee.util.Utility.parseToDefaultTimeZone;

/**
* The User Account Class to wrap User Details
*/
Expand Down Expand Up @@ -77,4 +83,21 @@ public String getCreatedAt() {
public String getUpdatedAt() {
return updatedAt;
}

/**
* Get the account creation Date/Time in ZonedDateTime format
* @return the date at which the message was sent/created/received
*/
public ZonedDateTime getCreatedDateTime() throws DateTimeParserException {
return parseToDefaultTimeZone(createdAt, "yyyy-MM-dd'T'HH:mm:ss'+00:00'");
}

/**
* Get the account update Date/Time in ZonedDateTime format
* @return the date on which the message was updated (markAsRead fires the update event)
* @see me.shivzee.callbacks.EventListener
*/
public ZonedDateTime getUpdatedDateTime() throws DateTimeParserException {
return parseToDefaultTimeZone(updatedAt, "yyyy-MM-dd'T'HH:mm:ss'+00:00'");
}
}

0 comments on commit 0078e33

Please sign in to comment.