Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

replace SimpleDateFormat with equivalent from joda lib #289

Merged
merged 1 commit into from

2 participants

@pkozikow
Owner

No description provided.

@thomas-kielbus

Great, thank you!

@thomas-kielbus thomas-kielbus merged commit c4c68d6 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jun 27, 2014
This page is out of date. Refresh to see the latest.
View
6 hank-ui/pom.xml
@@ -142,6 +142,12 @@
<version>3.2.0.RELEASE</version>
</dependency>
+ <dependency>
+ <groupId>joda-time</groupId>
+ <artifactId>joda-time</artifactId>
+ <version>2.3</version>
+ </dependency>
+
</dependencies>
<build>
View
13 hank-ui/src/main/java/com/liveramp/hank/monitor/notification/AbstractNotification.java
@@ -1,16 +1,17 @@
package com.liveramp.hank.monitor.notification;
-import com.liveramp.hank.monitor.notifier.Notification;
-
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
import java.util.Date;
+import org.joda.time.format.DateTimeFormat;
+import org.joda.time.format.DateTimeFormatter;
+
+import com.liveramp.hank.monitor.notifier.Notification;
+
public abstract class AbstractNotification implements Notification {
private final Date date;
private static final String DATE_FORMAT = "yy/MM/dd HH:mm:ss";
- private static final DateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT);
+ private static final DateTimeFormatter dateFormat = DateTimeFormat.forPattern(DATE_FORMAT);
public AbstractNotification() {
date = new Date();
@@ -25,6 +26,6 @@ public Date getDate() {
@Override
public final String format(NotificationFormatter formatter) {
- return dateFormat.format(date) + " " + formatCore(formatter);
+ return dateFormat.print(date.getTime()) + " " + formatCore(formatter);
}
}
View
33 hank-ui/src/main/java/com/liveramp/hank/ui/UiUtils.java
@@ -1,16 +1,31 @@
package com.liveramp.hank.ui;
-import com.liveramp.hank.coordinator.*;
+import java.io.IOException;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeSet;
+import java.util.UUID;
+
+import org.apache.commons.lang.StringUtils;
+import org.joda.time.format.DateTimeFormat;
+import org.joda.time.format.DateTimeFormatter;
+
+import com.liveramp.hank.coordinator.Domain;
+import com.liveramp.hank.coordinator.DomainAndVersion;
+import com.liveramp.hank.coordinator.DomainGroup;
+import com.liveramp.hank.coordinator.DomainVersion;
+import com.liveramp.hank.coordinator.Host;
+import com.liveramp.hank.coordinator.HostState;
+import com.liveramp.hank.coordinator.Ring;
+import com.liveramp.hank.coordinator.RingGroup;
+import com.liveramp.hank.coordinator.UpdateProgress;
+import com.liveramp.hank.coordinator.UpdateProgressAggregator;
import com.liveramp.hank.partition_server.DoublePopulationStatisticsAggregator;
import com.liveramp.hank.partition_server.FilesystemStatisticsAggregator;
import com.liveramp.hank.partition_server.RuntimeStatisticsAggregator;
import com.liveramp.hank.util.FormatUtils;
-import org.apache.commons.lang.StringUtils;
-
-import java.io.IOException;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.*;
public class UiUtils {
@@ -18,7 +33,7 @@ private UiUtils() {
}
private static final int BAR_SIZE = 100;
- private static DateFormat dateFormat = new SimpleDateFormat("d MMM yyyy HH:mm:ss");
+ private static DateTimeFormatter dateFormat = DateTimeFormat.forPattern("d MMM yyyy HH:mm:ss");
public static String hostStateToClass(HostState state) throws IOException {
switch (state) {
@@ -133,7 +148,7 @@ public static String formatDomainVersionClosedAt(DomainVersion domainVersion) th
if (closedAt == null) {
return "-";
} else {
- return dateFormat.format(new Date(closedAt));
+ return dateFormat.print(closedAt);
}
}
View
6 hank-ui/src/main/java/com/liveramp/hank/ui/host.jsp
@@ -7,9 +7,9 @@
<%@page import="com.liveramp.hank.util.*" %>
<%@page import="java.util.*" %>
<%@page import="java.text.DecimalFormat" %>
- <%@page import="java.text.SimpleDateFormat" %>
+ <%@page import="org.joda.time.format.DateTimeFormat" %>
- <%
+ <%
Coordinator coord = (Coordinator)getServletContext().getAttribute("coordinator");
RingGroup ringGroup = coord.getRingGroup(request.getParameter("g"));
Ring ring = ringGroup.getRing(Integer.parseInt(request.getParameter("r")));
@@ -139,7 +139,7 @@
<% if (upSince == null) { %>
undefined
<% } else { %>
- Started <%= new SimpleDateFormat().format(new Date(upSince)) %>
+ Started <%= DateTimeFormat.forStyle("SS").print(upSince) %>
(online for <%= FormatUtils.formatSecondsDuration((System.currentTimeMillis() - upSince) / 1000) %>)
<% } %>
</td>
View
4 hank-ui/src/main/java/com/liveramp/hank/ui/ring_group.jsp
@@ -14,7 +14,7 @@
<%@page import="org.apache.thrift.*" %>
<%@page import="org.apache.commons.lang.StringEscapeUtils" %>
<%@page import="java.text.DecimalFormat" %>
- <%@page import="java.text.SimpleDateFormat" %>
+ <%@page import="org.joda.time.format.DateTimeFormat" %>
<%
@@ -532,7 +532,7 @@ Collections.sort(clients, new ClientMetadataComparator());
<%= FormatUtils.formatSecondsDuration((System.currentTimeMillis() - client.get_connected_at()) / 1000) %>
</td>
<td>
- <%= new SimpleDateFormat().format(new Date(client.get_connected_at())) %>
+ <%= DateTimeFormat.forStyle("SS").print(client.get_connected_at()) %>
</td>
<td><%= client.get_type() %></td>
<td><%= client.get_version() %></td>
Something went wrong with that request. Please try again.