aboutsummaryrefslogtreecommitdiffstats
path: root/src/net
diff options
context:
space:
mode:
authorDamian Minkov <damencho@jitsi.org>2012-03-09 15:32:07 +0000
committerDamian Minkov <damencho@jitsi.org>2012-03-09 15:32:07 +0000
commit5caa0b04f202f0f93562b9cb83d7e304d0483e02 (patch)
tree76089edba30877f319acf6043105a92cf3dca188 /src/net
parentd9bef7b03a7c81e26a25ec876cea7477bc3d9689 (diff)
downloadjitsi-5caa0b04f202f0f93562b9cb83d7e304d0483e02.zip
jitsi-5caa0b04f202f0f93562b9cb83d7e304d0483e02.tar.gz
jitsi-5caa0b04f202f0f93562b9cb83d7e304d0483e02.tar.bz2
Fixes call duration counter when call is longer than 24 hours.
Diffstat (limited to 'src/net')
-rw-r--r--src/net/java/sip/communicator/impl/callhistory/CallHistorySourceContact.java3
-rw-r--r--src/net/java/sip/communicator/impl/gui/main/call/CallInfoFrame.java7
-rw-r--r--src/net/java/sip/communicator/impl/gui/main/call/CallPanel.java16
-rw-r--r--src/net/java/sip/communicator/util/GuiUtils.java55
4 files changed, 41 insertions, 40 deletions
diff --git a/src/net/java/sip/communicator/impl/callhistory/CallHistorySourceContact.java b/src/net/java/sip/communicator/impl/callhistory/CallHistorySourceContact.java
index 2763089..51a4593 100644
--- a/src/net/java/sip/communicator/impl/callhistory/CallHistorySourceContact.java
+++ b/src/net/java/sip/communicator/impl/callhistory/CallHistorySourceContact.java
@@ -90,8 +90,7 @@ public class CallHistorySourceContact implements SourceContact
+ " " + CallHistoryActivator.getResources()
.getI18NString("service.gui.DURATION") + ": "
+ GuiUtils.formatTime(
- GuiUtils.substractDates(
- callRecord.getEndTime(), callRecord.getStartTime()));
+ callRecord.getStartTime(), callRecord.getEndTime());
}
/**
diff --git a/src/net/java/sip/communicator/impl/gui/main/call/CallInfoFrame.java b/src/net/java/sip/communicator/impl/gui/main/call/CallInfoFrame.java
index cac2c08..5e92fc4 100644
--- a/src/net/java/sip/communicator/impl/gui/main/call/CallInfoFrame.java
+++ b/src/net/java/sip/communicator/impl/gui/main/call/CallInfoFrame.java
@@ -237,13 +237,10 @@ public class CallInfoFrame
CallPeer.CALL_DURATION_START_TIME_UNKNOWN)
{
Date startTime = new Date(callPeer.getCallDurationStartTime());
- Date currentTime = new Date(System.currentTimeMillis());
- Date callNbTimeMsSpent = GuiUtils.substractDates(
- currentTime,
- startTime);
stringBuffer.append(getLineString(
resources.getI18NString("service.gui.callinfo.CALL_DURATION"),
- GuiUtils.formatTime(callNbTimeMsSpent)));
+ GuiUtils.formatTime(startTime.getTime(),
+ System.currentTimeMillis())));
}
if(callPeer instanceof MediaAwareCallPeer)
diff --git a/src/net/java/sip/communicator/impl/gui/main/call/CallPanel.java b/src/net/java/sip/communicator/impl/gui/main/call/CallPanel.java
index 9f522c9..6ca52d0 100644
--- a/src/net/java/sip/communicator/impl/gui/main/call/CallPanel.java
+++ b/src/net/java/sip/communicator/impl/gui/main/call/CallPanel.java
@@ -1021,23 +1021,21 @@ public class CallPanel
{
public void actionPerformed(ActionEvent e)
{
- Date time =
- GuiUtils.substractDates(new Date(), callStartDate);
-
- setCallTitle(time);
+ setCallTitle(callStartDate);
}
}
/**
- * Sets the title of this dialog by specifying the call duration.
- * @param callDuration the duration of the call represented as Date object
+ * Sets the title of this dialog by specifying the call duration till now.
+ * @param startDate the call start date
*/
- private void setCallTitle(Date callDuration)
+ private void setCallTitle(Date startDate)
{
Iterator<? extends CallPeer> callPeers = call.getCallPeers();
- if (callDuration != null)
- title = GuiUtils.formatTime(callDuration) + " | ";
+ if (startDate != null)
+ title = GuiUtils.formatTime(startDate.getTime(),
+ System.currentTimeMillis()) + " | ";
else
title = "00:00:00 | ";
diff --git a/src/net/java/sip/communicator/util/GuiUtils.java b/src/net/java/sip/communicator/util/GuiUtils.java
index c58cf4b..a106bde 100644
--- a/src/net/java/sip/communicator/util/GuiUtils.java
+++ b/src/net/java/sip/communicator/util/GuiUtils.java
@@ -351,37 +351,44 @@ public class GuiUtils
GuiUtils.formatTime(c1.get(Calendar.SECOND), timeStrBuf);
return timeStrBuf.toString();
}
+
+ /**
+ * Formats the time period duration for the given start date and end date.
+ * The result format is the following:
+ * [Hour]:[Minute]:[Second]. For example: 12:25:30.
+ * @param startDate the start date
+ * @param endDate the end date
+ * @return the formatted hour string
+ */
+ public static String formatTime(Date startDate, Date endDate)
+ {
+ return formatTime(startDate.getTime(), endDate.getTime());
+ }
/**
- * Subtracts the two dates.
- * @param date1 the first date argument
- * @param date2 the second date argument
- * @return the date resulted from the substracting
+ * Formats the time period duration for the given start date and end date.
+ * The result format is the following:
+ * [Hour]:[Minute]:[Second]. For example: 12:25:30.
+ * @param start the start date in milliseconds
+ * @param end the end date in milliseconds
+ * @return the formatted hour string
*/
- public static Date substractDates(Date date1, Date date2)
+ public static String formatTime(long start, long end)
{
- long d1 = date1.getTime();
- long d2 = date2.getTime();
- long difMil = d1-d2;
- long milPerDay = 1000*60*60*24;
- long milPerHour = 1000*60*60;
- long milPerMin = 1000*60;
- long milPerSec = 1000;
+ long duration = end - start;
- long days = difMil / milPerDay;
- int hour = (int)(( difMil - days*milPerDay ) / milPerHour);
- int min
- = (int)(( difMil - days*milPerDay - hour*milPerHour ) / milPerMin);
- int sec
- = (int)(( difMil - days*milPerDay - hour*milPerHour - min*milPerMin)
- / milPerSec);
+ long milPerSec = 1000;
+ long milPerMin = milPerSec*60;
+ long milPerHour = milPerMin*60;
- c1.clear();
- c1.set(Calendar.HOUR, hour);
- c1.set(Calendar.MINUTE, min);
- c1.set(Calendar.SECOND, sec);
+ long hours = duration / milPerHour;
+ long minutes
+ = ( duration - hours*milPerHour ) / milPerMin;
+ long seconds
+ = ( duration - hours*milPerHour - minutes*milPerMin)
+ / milPerSec;
- return c1.getTime();
+ return String.format("%02d:%02d:%02d", hours, minutes, seconds);
}
/**