Skip to content

Commit

Permalink
Merge branch '7.3' of github.com:gchq/stroom into gh-4150_show_not_vis
Browse files Browse the repository at this point in the history
  • Loading branch information
stroomdev66 committed Mar 11, 2024
2 parents ef011d6 + 8def0ca commit 7d772e7
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 10 deletions.
6 changes: 4 additions & 2 deletions stroom-app-gwt/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ def workDir = "${gwtBuildDir}/work"
def deployDir = "${gwtBuildDir}/deploy"
def extraDir = "${gwtBuildDir}/extra"


def allSourceDir = "${gwtBuildDir}/all-source"
def transformedSourceDir = "${gwtBuildDir}/transformed-source"
def transformedBuildDir = "${gwtBuildDir}/transformed-build"
Expand Down Expand Up @@ -212,6 +211,7 @@ tasks.register('makeGwtSourceDirs') {
doLast {
def rsyncInputDir = "${gwtBuildDir}/rsync-input"
delete rsyncInputDir
new File(rsyncInputDir).mkdirs()

def start = Instant.now()

Expand Down Expand Up @@ -273,7 +273,6 @@ tasks.register('makeGwtSourceDirs') {
tasks.register('gwtCompile', JavaExec) {
dependsOn classes
group "gwt"
dependsOn 'gwtClean'
dependsOn 'makeGwtSourceDirs'

def module = 'stroom.app.App'
Expand Down Expand Up @@ -483,3 +482,6 @@ tasks.register('gwtClean') {
new File(gwtTmpDir).mkdirs()
}
}

tasks.clean.dependsOn(tasks.gwtClean)

Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,14 @@ public String format(final Long ms) {
}

Use use = Use.UTC;
String pattern = "YYYY-MM-DDTHH:mm:ss.SSS[Z]";
String pattern = "YYYY-MM-DD[T]HH:mm:ss.SSSZ";
int offsetMinutes = 0;
String zoneId = "UTC";

final UserPreferences userPreferences = userPreferencesManager.getCurrentUserPreferences();
if (userPreferences != null) {
if (userPreferences.getDateTimePattern() != null
&& userPreferences.getDateTimePattern().trim().length() > 0) {
pattern = userPreferences.getDateTimePattern();
pattern = convertJavaDateTimePattern(pattern);
if (userPreferences.getDateTimePattern() != null &&
userPreferences.getDateTimePattern().trim().length() > 0) {

final TimeZone timeZone = userPreferences.getTimeZone();
if (timeZone != null) {
Expand All @@ -62,9 +60,20 @@ public String format(final Long ms) {

zoneId = timeZone.getId();
}

pattern = userPreferences.getDateTimePattern();
pattern = convertJavaDateTimePattern(pattern);
}
}

// If UTC then just display the `Z` suffix.
if (Use.UTC.equals(use)) {
pattern = pattern.replaceAll("Z", "[Z]");
}
// Ensure we haven't doubled up square brackets.
pattern = pattern.replaceAll("\\[+", "[");
pattern = pattern.replaceAll("]+", "]");

return nativeToDateString(ms, use.getDisplayValue(), pattern, zoneId, offsetMinutes);
}

Expand All @@ -73,7 +82,8 @@ String convertJavaDateTimePattern(final String pattern) {
converted = converted.replace('y', 'Y');
converted = converted.replace('d', 'D');
converted = converted.replaceAll("'", "");
converted = converted.replaceAll("SSSXX", "SSS[Z]");
converted = converted.replaceAll("SSSXX", "SSSZ");
converted = converted.replaceAll("T", "[T]");
converted = converted.replaceAll("xxx", "Z");
converted = converted.replaceAll("xx", "z");
converted = converted.replaceAll("VV", "ZZ");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ void test() {
final DateTimeFormatter dateTimeFormatter = new DateTimeFormatter(null);
assertThat(dateTimeFormatter
.convertJavaDateTimePattern("yyyy-MM-dd'T'HH:mm:ss.SSSXX"))
.isEqualTo("YYYY-MM-DDTHH:mm:ss.SSS[Z]");
.isEqualTo("YYYY-MM-DD[T]HH:mm:ss.SSSZ");
assertThat(dateTimeFormatter
.convertJavaDateTimePattern("yyyy-MM-dd'T'HH'#'mm'#'ss,SSSXX"))
.isEqualTo("YYYY-MM-DDTHH#mm#ss,SSS[Z]");
.isEqualTo("YYYY-MM-DD[T]HH#mm#ss,SSSZ");
assertThat(dateTimeFormatter
.convertJavaDateTimePattern("E, dd MMM yyyy HH:mm:ss Z"))
.isEqualTo("ddd, DD MMM YYYY HH:mm:ss Z");
Expand Down
24 changes: 24 additions & 0 deletions unreleased_changes/20240308_095510_520__4152.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
* Issue **#4152** : Fix date time formatter always showing `Z` when it should show actual timezone.


```sh
# ********************************************************************************
# Issue title: When displaying date/times as non UTC, Stroom incorrectly showing `Z` suffix as opposed to actual offset
# Issue link: https://github.com/gchq/stroom/issues/4152
# ********************************************************************************

# ONLY the top line will be included as a change entry in the CHANGELOG.
# The entry should be in GitHub flavour markdown and should be written on a SINGLE
# line with no hard breaks. You can have multiple change files for a single GitHub issue.
# The entry should be written in the imperative mood, i.e. 'Fix nasty bug' rather than
# 'Fixed nasty bug'.
#
# Examples of acceptable entries are:
#
#
# * Issue **123** : Fix bug with an associated GitHub issue in this repository
#
# * Issue **namespace/other-repo#456** : Fix bug with an associated GitHub issue in another repository
#
# * Fix bug with no associated GitHub issue.
```

0 comments on commit 7d772e7

Please sign in to comment.