Skip to content

Commit

Permalink
Add iso method to DateTimeUtils class
Browse files Browse the repository at this point in the history
  • Loading branch information
dolfinus committed May 10, 2019
1 parent f4cd048 commit 955047b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/org/camunda/latera/bss/connectors/odoo/Main.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ trait Main {
}

if (DateTimeUtil.isDate(value)) {
content = DateTimeUtil.format(value, DateTimeUtil.ISO_FORMAT)
content = DateTimeUtil.iso(value)
}
query += """('${field}','${condition}','${content}')"""
}
Expand Down
12 changes: 12 additions & 0 deletions src/org/camunda/latera/bss/utils/DateTimeUtil.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,18 @@ class DateTimeUtil {
return format(input, params.format, params.locale)
}

static String iso(Date input) {
return input.format(this.ISO_FORMAT_NO_TZ)
}

static String iso(LocalDateTime input) {
return input.format(this.ISO_FORMAT_NO_TZ)
}

static String iso(ZonedDateTime input) {
return input.format(this.ISO_FORMAT)
}

static ZonedDateTime atZone(Date input, ZoneId zone) {
return input.toInstant().atZone(zone)
}
Expand Down
6 changes: 1 addition & 5 deletions src/org/camunda/latera/bss/utils/JSON.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,7 @@ class JSON {
}
return newList
} else if (DateTimeUtil.isDate(obj)) {
try {
return DateTimeUtil.format(obj, DateTimeUtil.ISO_FORMAT)
} catch(Exception e) {
return DateTimeUtil.format(obj, DateTimeUtil.ISO_FORMAT_NO_TZ)
}
return DateTimeUtil.iso(obj)
} else {
return obj
}
Expand Down

0 comments on commit 955047b

Please sign in to comment.