Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added "epochms" and "epoch" masks to DateTimeFormat #1233

Merged
merged 2 commits into from
Apr 7, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,16 @@ public static String invoke(DateTime datetime, String mask, Locale locale, TimeZ
else if ("long".equalsIgnoreCase(mask)) format = java.text.DateFormat.getDateTimeInstance(java.text.DateFormat.LONG, java.text.DateFormat.LONG, locale);
else if ("full".equalsIgnoreCase(mask)) format = java.text.DateFormat.getDateTimeInstance(java.text.DateFormat.FULL, java.text.DateFormat.FULL, locale);
else if ("iso8601".equalsIgnoreCase(mask) || "iso".equalsIgnoreCase(mask)) format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX");
else if ("epoch".equalsIgnoreCase(mask)) {
String gettime = String.valueOf(datetime.getTime() / 1000);
String epoch = gettime.toString();
return epoch;
}
else if ("epochms".equalsIgnoreCase(mask)) {
String gettime = String.valueOf(datetime.getTime());
String epoch = gettime.toString();
return epoch;
}
else {
SimpleDateFormat sdf;
format = sdf = new SimpleDateFormat(convertMask(mask), locale);
Expand Down
1 change: 1 addition & 0 deletions core/src/main/java/resource/fld/core-cfml.fld
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,7 @@ The following masks can be used to format the full date and time and may not be
- long: medium followed by three-letter time zone; i.e. "mmmm d, yyyy h:nn:ss tt zzz"
- full: equivalent to "dddd, mmmm d, yyyy h:nn:ss tt zz"
- ISO8601/ISO: equivalent to "yyyy-mm-dd'T'HH:nn:ssXXX"
- epoch: Total seconds of a given date (Example:1567517664)
zspitzer marked this conversation as resolved.
Show resolved Hide resolved

The function follows Java date time mask. For details, see the section Date and Time Patterns at http://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html
</description>
Expand Down