diff --git a/core/src/main/java/hudson/model/TimeZoneProperty.java b/core/src/main/java/hudson/model/TimeZoneProperty.java index 65fc783a261ca2fa7e4c14093db1bb55eaa3e1ed..0a75b473ed4144d0d7363af21772137d99d1a954 100644 --- a/core/src/main/java/hudson/model/TimeZoneProperty.java +++ b/core/src/main/java/hudson/model/TimeZoneProperty.java @@ -6,6 +6,10 @@ import hudson.util.ListBoxModel.Option; import edu.umd.cs.findbugs.annotations.CheckForNull; import edu.umd.cs.findbugs.annotations.NonNull; import edu.umd.cs.findbugs.annotations.Nullable; +import hudson.Util; +import hudson.util.FormValidation; +import java.text.DateFormat; +import java.util.Date; import java.util.TimeZone; import java.util.logging.Logger; import java.util.logging.Level; @@ -13,6 +17,7 @@ import org.jenkinsci.Symbol; import org.kohsuke.stapler.DataBoundConstructor; import org.kohsuke.accmod.Restricted; import org.kohsuke.accmod.restrictions.NoExternalUse; +import org.kohsuke.stapler.QueryParameter; /** @@ -85,6 +90,18 @@ public class TimeZoneProperty extends UserProperty { } return items; } + + public FormValidation doCheckTimeZoneName(@QueryParameter String timeZoneName) { + Date now = new Date(); + if (Util.fixEmpty(timeZoneName) == null) { + return FormValidation.ok(Messages.TimeZoneProperty_current_time_in_(TimeZone.getDefault().getDisplayName(), DateFormat.getDateTimeInstance().format(now))); + } else { + DateFormat localTime = DateFormat.getDateTimeInstance(); + localTime.setTimeZone(TimeZone.getTimeZone(timeZoneName)); + return FormValidation.ok(Messages.TimeZoneProperty_current_time_on_server_in_in_proposed_di(TimeZone.getDefault().getDisplayName(), DateFormat.getDateTimeInstance().format(now), localTime.format(now))); + } + } + } @Nullable diff --git a/core/src/main/resources/hudson/model/Messages.properties b/core/src/main/resources/hudson/model/Messages.properties index 396d916f5599eac147feceb52610915ccb355000..5dfe7e5dc2b3246e279e6189ded29e2afe9286d1 100644 --- a/core/src/main/resources/hudson/model/Messages.properties +++ b/core/src/main/resources/hudson/model/Messages.properties @@ -403,6 +403,8 @@ User.IllegalFullname="{0}" is prohibited as a full name for security reasons. TimeZoneProperty.DisplayName=User Defined Time Zone TimeZoneProperty.DisplayDefaultTimeZone=Default +TimeZoneProperty.current_time_in_=Current time in {0}: {1} +TimeZoneProperty.current_time_on_server_in_in_proposed_di=Current time on server in {0}: {1}; in proposed display zone: {2} ManagementLink.Category.CONFIGURATION=System Configuration ManagementLink.Category.SECURITY=Security diff --git a/core/src/main/resources/hudson/model/TimeZoneProperty/config.properties b/core/src/main/resources/hudson/model/TimeZoneProperty/config.properties index bb7f46fc426b4e24959f6afcff96feae1b6ecefa..df0ea286bace88cf77249d4187f27b8432a983fe 100644 --- a/core/src/main/resources/hudson/model/TimeZoneProperty/config.properties +++ b/core/src/main/resources/hudson/model/TimeZoneProperty/config.properties @@ -18,4 +18,3 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. title=Time Zone -description=Specify user defined time zone for displaying time rather than system default. diff --git a/core/src/main/resources/hudson/model/TimeZoneProperty/help-timeZoneName.html b/core/src/main/resources/hudson/model/TimeZoneProperty/help-timeZoneName.html new file mode 100644 index 0000000000000000000000000000000000000000..b6b91671a4a0fc0a246440c86b428538c235ec0a --- /dev/null +++ b/core/src/main/resources/hudson/model/TimeZoneProperty/help-timeZoneName.html @@ -0,0 +1,3 @@ +
+ Specify user defined time zone for displaying time rather than system default. +