Log dates in all history files as ISO 8601 with timezone

cusax-fix
Ingo Bauersachs 14 years ago
parent 14c78d292c
commit 83e15ea8e2

@ -7,6 +7,7 @@
package net.java.sip.communicator.impl.callhistory;
import java.io.*;
import java.text.*;
import java.util.*;
import net.java.sip.communicator.service.callhistory.*;
@ -380,6 +381,7 @@ static CallRecord convertHistoryRecordToCallRecord(HistoryRecord hr)
// 4 - callParticipantStart
// 5 - callParticipantEnd
SimpleDateFormat sdf = new SimpleDateFormat(HistoryService.DATE_FORMAT);
for (int i = 0; i < hr.getPropertyNames().length; i++)
{
String propName = hr.getPropertyNames()[i];
@ -388,9 +390,23 @@ static CallRecord convertHistoryRecordToCallRecord(HistoryRecord hr)
if (propName.equals(STRUCTURE_NAMES[0]))
result.setProtocolProvider(getProtocolProvider(value));
else if(propName.equals(STRUCTURE_NAMES[1]))
result.setStartTime(new Date(Long.parseLong(value)));
try
{
result.setStartTime(sdf.parse(value));
}
catch (ParseException e)
{
result.setStartTime(new Date(Long.parseLong(value)));
}
else if(propName.equals(STRUCTURE_NAMES[2]))
result.setEndTime(new Date(Long.parseLong(value)));
try
{
result.setEndTime(sdf.parse(value));
}
catch (ParseException e)
{
result.setEndTime(new Date(Long.parseLong(value)));
}
else if(propName.equals(STRUCTURE_NAMES[3]))
result.setDirection(value);
else if(propName.equals(STRUCTURE_NAMES[4]))
@ -418,8 +434,15 @@ else if(propName.equals(STRUCTURE_NAMES[9]))
if (i < callPeerStart.size())
{
callPeerStartValue
= new Date(Long.parseLong(callPeerStart.get(i)));
try
{
callPeerStartValue = sdf.parse(callPeerStart.get(i));
}
catch (ParseException e)
{
callPeerStartValue
= new Date(Long.parseLong(callPeerStart.get(i)));
}
}
else
{
@ -432,8 +455,15 @@ else if(propName.equals(STRUCTURE_NAMES[9]))
if (i < callPeerEnd.size())
{
callPeerEndValue
= new Date(Long.parseLong(callPeerEnd.get(i)));
try
{
callPeerEndValue = sdf.parse(callPeerEnd.get(i));
}
catch (ParseException e)
{
callPeerEndValue
= new Date(Long.parseLong(callPeerEnd.get(i)));
}
}
else
{
@ -645,6 +675,8 @@ private void writeCall( CallRecordImpl callRecord,
{
try
{
SimpleDateFormat sdf
= new SimpleDateFormat(HistoryService.DATE_FORMAT);
History history = this.getHistory(source, destination);
HistoryWriter historyWriter = history.getWriter();
@ -668,18 +700,16 @@ private void writeCall( CallRecordImpl callRecord,
callPeerIDs.append(item.getPeerAddress());
callPeerNames.append(item.getDisplayName());
callPeerStartTime.append(String.valueOf(item
.getStartTime().getTime()));
callPeerEndTime.append(String.valueOf(item.getEndTime()
.getTime()));
callPeerStartTime.append(sdf.format(item.getStartTime()));
callPeerEndTime.append(sdf.format(item.getEndTime()));
callPeerStates.append(item.getState().getStateString());
}
historyWriter.addRecord(new String[] {
callRecord.getSourceCall().getProtocolProvider()
.getAccountID().getAccountUniqueID(),
String.valueOf(callRecord.getStartTime().getTime()),
String.valueOf(callRecord.getEndTime().getTime()),
sdf.format(callRecord.getStartTime()),
sdf.format(callRecord.getEndTime()),
callRecord.getDirection(),
callPeerIDs.toString(),
callPeerStartTime.toString(),

@ -6,7 +6,11 @@
*/
package net.java.sip.communicator.impl.filehistory;
import static
net.java.sip.communicator.service.history.HistoryService.DATE_FORMAT;
import java.io.*;
import java.text.*;
import java.util.*;
import net.java.sip.communicator.service.contactlist.*;
@ -227,10 +231,11 @@ private FileRecord createFileRecordFromHistoryRecord(
{
String file = null;
String dir = null;
long date = 0;
Date date = new Date(0);
String status = null;
String id = null;
SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
for (int i = 0; i < hr.getPropertyNames().length; i++)
{
String propName = hr.getPropertyNames()[i];
@ -243,11 +248,11 @@ else if (propName.equals(STRUCTURE_NAMES[2]))
{
try
{
date = Long.valueOf(hr.getPropertyValues()[i]);
date = sdf.parse(hr.getPropertyValues()[i]);
}
catch (NumberFormatException e)
catch (ParseException e)
{
logger.error("Wrong date : " + hr.getPropertyValues()[i]);
date = new Date(Long.valueOf(hr.getPropertyValues()[i]));
}
}
else if (propName.equals(STRUCTURE_NAMES[3]))
@ -760,10 +765,12 @@ public void fileTransferRequestReceived(FileTransferRequestEvent event)
History history = getHistory(null, req.getSender());
HistoryWriter historyWriter = history.getWriter();
SimpleDateFormat sdf
= new SimpleDateFormat(HistoryService.DATE_FORMAT);
historyWriter.addRecord(new String[]{
req.getFileName(),
getDirection(FileTransfer.IN),
String.valueOf(event.getTimestamp().getTime()),
sdf.format(event.getTimestamp()),
FILE_TRANSFER_ACTIVE,
req.getID()
});
@ -799,10 +806,13 @@ public void fileTransferCreated(FileTransferCreatedEvent event)
}
else if (fileTransfer.getDirection() == FileTransfer.OUT)
{
SimpleDateFormat sdf
= new SimpleDateFormat(HistoryService.DATE_FORMAT);
historyWriter.addRecord(new String[]{
fileTransfer.getLocalFile().getCanonicalPath(),
getDirection(FileTransfer.OUT),
String.valueOf(event.getTimestamp().getTime()),
sdf.format(event.getTimestamp()),
FILE_TRANSFER_ACTIVE,
fileTransfer.getID()
});
@ -874,10 +884,10 @@ private static class FileRecordComparator
{
public int compare(FileRecord o1, FileRecord o2)
{
long date1 = o1.getDate();
long date2 = o2.getDate();
Date date1 = o1.getDate();
Date date2 = o2.getDate();
return (date1 < date2) ? -1 : ((date1 == date2) ? 0 : 1);
return date1.compareTo(date2);
}
}
}

@ -296,7 +296,7 @@ protected void openFile(File downloadFile)
*/
public String getDateString(Date date)
{
return ChatHtmlUtils.getDateString(date.getTime())
return ChatHtmlUtils.getDateString(date)
+ GuiUtils.formatTime(date)
+ " ";
}

@ -11,6 +11,7 @@
import java.awt.event.*;
import java.io.*;
import java.net.*;
import java.text.*;
import java.util.*;
import java.util.regex.*;
@ -29,6 +30,7 @@
import net.java.sip.communicator.plugin.desktoputil.*;
import net.java.sip.communicator.plugin.desktoputil.SwingWorker;
import net.java.sip.communicator.service.gui.*;
import net.java.sip.communicator.service.history.*;
import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.service.replacement.*;
import net.java.sip.communicator.service.replacement.smilies.*;
@ -136,12 +138,12 @@ public class ChatConversationPanel
/**
* The timestamp of the last incoming message.
*/
private long lastIncomingMsgTimestamp;
private Date lastIncomingMsgTimestamp = new Date(0);
/**
* The timestamp of the last message.
*/
private long lastMessageTimestamp;
private Date lastMessageTimestamp = new Date(0);
/**
* Indicates if this component is rendering a history conversation.
@ -415,7 +417,7 @@ public String processMessage( ChatMessage chatMessage,
= contactDisplayName.replaceAll("&apos;", "&#39;");
}
long date = chatMessage.getDate();
Date date = chatMessage.getDate();
String messageType = chatMessage.getMessageType();
String messageTitle = chatMessage.getMessageTitle();
String message = chatMessage.getMessage();
@ -435,7 +437,7 @@ public String processMessage( ChatMessage chatMessage,
if (messageType.equals(Chat.INCOMING_MESSAGE))
{
this.lastIncomingMsgTimestamp = System.currentTimeMillis();
this.lastIncomingMsgTimestamp = new Date();
chatString = ChatHtmlUtils.createIncomingMessageTag(
lastMessageUID,
@ -1227,7 +1229,7 @@ public JTextPane getChatTextPane()
*
* @return The time of the last received message.
*/
public long getLastIncomingMsgTimestamp()
public Date getLastIncomingMsgTimestamp()
{
return lastIncomingMsgTimestamp;
}
@ -1428,7 +1430,15 @@ public Date getPageFirstMsgTimestamp()
.getAttributes().getAttribute(ChatHtmlUtils.DATE_ATTRIBUTE)
.toString();
return new Date(Long.parseLong(dateObject));
SimpleDateFormat sdf = new SimpleDateFormat(HistoryService.DATE_FORMAT);
try
{
return sdf.parse(dateObject);
}
catch (ParseException e)
{
return new Date(0);
}
}
/**
@ -1438,7 +1448,7 @@ public Date getPageFirstMsgTimestamp()
*/
public Date getPageLastMsgTimestamp()
{
long timestamp = 0;
Date timestamp = new Date(0);
if (lastMessageUID != null)
{
@ -1452,12 +1462,21 @@ public Date getPageLastMsgTimestamp()
= lastMsgElement.getAttributes().getAttribute(
ChatHtmlUtils.DATE_ATTRIBUTE);
SimpleDateFormat sdf
= new SimpleDateFormat(HistoryService.DATE_FORMAT);
if (date != null)
timestamp = Long.parseLong(date.toString());
{
try
{
timestamp = sdf.parse(date.toString());
}
catch (ParseException e)
{}
}
}
}
return new Date(timestamp);
return timestamp;
}
/**
@ -1596,8 +1615,10 @@ public void addComponent(ChatConversationComponent component)
style.addAttribute(StyleConstants.ComponentAttribute, wrapPanel);
style.addAttribute(Attribute.ID, ChatHtmlUtils.MESSAGE_TEXT_ID);
SimpleDateFormat sdf
= new SimpleDateFormat(HistoryService.DATE_FORMAT);
style.addAttribute(ChatHtmlUtils.DATE_ATTRIBUTE,
component.getDate().getTime());
sdf.format(component.getDate()));
scrollToBottomIsPending = true;
@ -1819,7 +1840,8 @@ private boolean isConsecutiveMessage(ChatMessage chatMessage)
.equals(Chat.HISTORY_OUTGOING_MESSAGE))
&& contactAddress.equals(chatMessage.getContactName())
// And if the new message is within a minute from the last one.
&& ((chatMessage.getDate() - lastMessageTimestamp)
&& ((chatMessage.getDate().getTime()
- lastMessageTimestamp.getTime())
< 60000))
{
lastMessageTimestamp = chatMessage.getDate();

@ -5,9 +5,13 @@
*/
package net.java.sip.communicator.impl.gui.main.chat;
import java.text.*;
import java.util.*;
import javax.swing.text.html.HTML.Tag;
import net.java.sip.communicator.impl.gui.*;
import net.java.sip.communicator.service.history.*;
import net.java.sip.communicator.util.*;
/**
@ -83,7 +87,7 @@ public static String createIncomingMessageTag(
String contactName,
String contactDisplayName,
String avatarPath,
long date,
Date date,
String message,
String contentType,
boolean isHistory,
@ -129,7 +133,7 @@ public static String createOutgoingMessageTag( String messageID,
String contactName,
String contactDisplayName,
String avatarPath,
long date,
Date date,
String message,
String contentType,
boolean isHistory,
@ -173,7 +177,7 @@ public static String createMessageTag( String messageID,
String contactName,
String message,
String contentType,
long date,
Date date,
boolean isEdited,
boolean isHistory,
boolean isSimpleTheme)
@ -215,15 +219,18 @@ private static String createSimpleIncomingMessageTag(
String contactName,
String contactDisplayName,
String avatarPath,
long date,
Date date,
String message,
String contentType,
boolean isHistory)
{
StringBuffer headerBuffer = new StringBuffer();
SimpleDateFormat sdf = new SimpleDateFormat(HistoryService.DATE_FORMAT);
headerBuffer.append("<h2 id=\"" + MESSAGE_HEADER_ID + "\" ");
headerBuffer.append(DATE_ATTRIBUTE + "='" + date + "'" + ">");
headerBuffer.append(DATE_ATTRIBUTE + "='"
+ sdf.format(date) + "'" + ">");
headerBuffer.append("<a style=\"color:#488fe7;");
headerBuffer.append("font-weight:bold;");
headerBuffer.append("text-decoration:none;\" ");
@ -278,15 +285,18 @@ private static String createSimpleOutgoingMessageTag( String messageID,
String contactName,
String contactDisplayName,
String avatarPath,
long date,
Date date,
String message,
String contentType,
boolean isHistory)
{
StringBuffer headerBuffer = new StringBuffer();
SimpleDateFormat sdf = new SimpleDateFormat(HistoryService.DATE_FORMAT);
headerBuffer.append("<h3 id=\"" + MESSAGE_HEADER_ID + "\" ");
headerBuffer.append(DATE_ATTRIBUTE + "='" + date + "'" + ">");
headerBuffer.append(DATE_ATTRIBUTE + "='"
+ sdf.format(date) + "'" + ">");
headerBuffer.append("<a style=\"color:#535353;");
headerBuffer.append("font-weight:bold;");
headerBuffer.append("text-decoration:none;\" ");
@ -342,15 +352,16 @@ private static String createAdvancedIncomingMessageTag(
String contactName,
String contactDisplayName,
String avatarPath,
long date,
Date date,
String message,
String contentType,
boolean isHistory)
{
StringBuffer headerBuffer = new StringBuffer();
SimpleDateFormat sdf = new SimpleDateFormat(HistoryService.DATE_FORMAT);
headerBuffer.append("<h2 id=\"" + MESSAGE_HEADER_ID + "\" ");
headerBuffer.append(DATE_ATTRIBUTE + "='" + date + "' ");
headerBuffer.append(DATE_ATTRIBUTE + "='" + sdf.format(date) + "' ");
headerBuffer.append(IncomingMessageStyle.createHeaderStyle() + ">");
headerBuffer.append("<a style=\"color:#488fe7;");
headerBuffer.append("font-weight:bold;");
@ -442,15 +453,16 @@ private static String createAdvancedOutgoingMessageTag( String messageID,
String contactName,
String contactDisplayName,
String avatarPath,
long date,
Date date,
String message,
String contentType,
boolean isHistory)
{
StringBuffer headerBuffer = new StringBuffer();
SimpleDateFormat sdf = new SimpleDateFormat(HistoryService.DATE_FORMAT);
headerBuffer.append("<h3 id=\"" + MESSAGE_HEADER_ID + "\" ");
headerBuffer.append(DATE_ATTRIBUTE + "='" + date + "' ");
headerBuffer.append(DATE_ATTRIBUTE + "='" + sdf.format(date) + "' ");
headerBuffer.append(IncomingMessageStyle.createHeaderStyle() + ">");
headerBuffer.append("<a style=\"color:#6a6868;");
headerBuffer.append("font-weight:bold;");
@ -536,7 +548,7 @@ private static String createAdvancedOutgoingMessageTag( String messageID,
* @return the message header tag
*/
private static String createAdvancedMessageHeaderTag(String nameHeader,
long date)
Date date)
{
StringBuffer messageHeader = new StringBuffer();
@ -642,16 +654,17 @@ private static String createSimpleMessageTag(String messageID,
String contactName,
String message,
String contentType,
long date,
Date date,
boolean isEdited,
boolean isHistory)
{
StringBuilder messageTag = new StringBuilder();
SimpleDateFormat sdf = new SimpleDateFormat(HistoryService.DATE_FORMAT);
messageTag.append(String.format("<div id='%s' %s = '%s' ",
MESSAGE_TEXT_ID + messageID, NAME_ATTRIBUTE,
contactName));
messageTag.append(DATE_ATTRIBUTE + "=\"" + date + "\" ");
messageTag.append(DATE_ATTRIBUTE + "=\"" + sdf.format(date) + "\" ");
messageTag.append(String.format("%s = '%s' ",
ORIGINAL_MESSAGE_ATTRIBUTE, GuiUtils.escapeHTMLChars(message)));
messageTag.append(IncomingMessageStyle
@ -685,16 +698,17 @@ private static String createAdvancedMessageTag( String messageID,
String contactName,
String message,
String contentType,
long date,
Date date,
boolean isEdited,
boolean isHistory)
{
StringBuilder messageTag = new StringBuilder();
SimpleDateFormat sdf = new SimpleDateFormat(HistoryService.DATE_FORMAT);
messageTag.append(String.format("<div id='%s' %s = '%s' ",
MESSAGE_TEXT_ID + messageID, NAME_ATTRIBUTE,
contactName));
messageTag.append(DATE_ATTRIBUTE + "=\"" + date + "\" ");
messageTag.append(DATE_ATTRIBUTE + "=\"" + sdf.format(date) + "\" ");
messageTag.append(String.format("%s = '%s' ",
ORIGINAL_MESSAGE_ATTRIBUTE, GuiUtils.escapeHTMLChars(message)));
messageTag.append(IncomingMessageStyle
@ -718,9 +732,9 @@ private static String createAdvancedMessageTag( String messageID,
* @param date the date to format
* @return the date string to show for the given date
*/
public static String getDateString(long date)
public static String getDateString(Date date)
{
if (GuiUtils.compareDatesOnly(date, System.currentTimeMillis()) <= 0)
if (GuiUtils.compareDatesOnly(date, new Date()) <= 0)
{
StringBuffer dateStrBuf = new StringBuffer();
@ -738,7 +752,7 @@ public static String getDateString(long date)
* @param date the date of the re-edition
* @return the newly constructed string
*/
private static String createEditedAt(long date)
private static String createEditedAt(Date date)
{
return "<font color=\"#b7b7b7\">(" + GuiActivator.getResources()
.getI18NString( "service.gui.EDITED_AT",

@ -6,6 +6,8 @@
*/
package net.java.sip.communicator.impl.gui.main.chat;
import java.util.*;
/**
* The <tt>ChatMessage</tt> class encapsulates message information in order to
* provide a single object containing all data needed to display a chat message.
@ -27,7 +29,7 @@ public class ChatMessage
/**
* The date and time of the message.
*/
private final long date;
private final Date date;
/**
* The type of the message.
@ -71,7 +73,7 @@ public class ChatMessage
* @param contentType the content type (e.g. "text", "text/html", etc.)
*/
public ChatMessage( String contactName,
long date,
Date date,
String messageType,
String message,
String contentType)
@ -91,7 +93,7 @@ public ChatMessage( String contactName,
* @param contentType the content type (e.g. "text", "text/html", etc.)
*/
public ChatMessage( String contactName,
long date,
Date date,
String messageType,
String messageTitle,
String message,
@ -113,7 +115,7 @@ public ChatMessage( String contactName,
*/
public ChatMessage( String contactName,
String contactDisplayName,
long date,
Date date,
String messageType,
String message,
String contentType)
@ -136,7 +138,7 @@ public ChatMessage( String contactName,
*/
public ChatMessage( String contactName,
String contactDisplayName,
long date,
Date date,
String messageType,
String messageTitle,
String message,
@ -180,7 +182,7 @@ public String getContactDisplayName()
*
* @return the date and time of the message.
*/
public long getDate()
public Date getDate()
{
return date;
}

@ -117,9 +117,9 @@ public class ChatPanel
public ChatSession chatSession;
private long firstHistoryMsgTimestamp;
private Date firstHistoryMsgTimestamp = new Date(0);
private long lastHistoryMsgTimestamp;
private Date lastHistoryMsgTimestamp = new Date(0);
private final List<ChatFocusListener> focusListeners
= new Vector<ChatFocusListener>();
@ -751,7 +751,7 @@ else if (o instanceof FileRecord)
* @param message the message text
* @param contentType the content type
*/
public void addMessage(String contactName, long date,
public void addMessage(String contactName, Date date,
String messageType, String message, String contentType)
{
addMessage(contactName, null, date, messageType, message, contentType,
@ -771,7 +771,7 @@ public void addMessage(String contactName, long date,
* @param message the message text
* @param contentType the content type
*/
public void addMessage(String contactName, String displayName, long date,
public void addMessage(String contactName, String displayName, Date date,
String messageType, String message, String contentType,
String messageUID, String correctedMessageUID)
{
@ -800,7 +800,7 @@ public void addMessage(String contactName, String displayName, long date,
* @param message the message text
* @param contentType the content type
*/
public void addMessage(String contactName, long date,
public void addMessage(String contactName, Date date,
String messageType, String title, String message, String contentType)
{
ChatMessage chatMessage = new ChatMessage(contactName, date,
@ -861,7 +861,8 @@ public void run()
public void addErrorMessage(String contactName,
String message)
{
this.addMessage(contactName, System.currentTimeMillis(),
this.addMessage(contactName,
new Date(),
Chat.ERROR_MESSAGE,
GuiActivator.getResources()
.getI18NString("service.gui.MSG_DELIVERY_FAILURE"),
@ -879,7 +880,8 @@ public void addErrorMessage(String contactName,
String title,
String message)
{
this.addMessage(contactName, System.currentTimeMillis(),
this.addMessage(contactName,
new Date(),
Chat.ERROR_MESSAGE,
title,
message, "text");
@ -978,7 +980,7 @@ private void applyMessageCorrection(ChatMessage message)
*/
private String processHistoryMessage(String contactName,
String contactDisplayName,
long date,
Date date,
String messageType,
String message,
String contentType)
@ -1005,7 +1007,7 @@ private String processHistoryMessage(String contactName,
*/
private String processHistoryMessage(String contactName,
String contactDisplayName,
long date,
Date date,
String messageType,
String message,
String contentType,
@ -1304,7 +1306,7 @@ public void sendFile( final File file,
{
addMessage(
chatSession.getCurrentChatTransport().getName(),
System.currentTimeMillis(),
new Date(),
Chat.ERROR_MESSAGE,
GuiActivator.getResources()
.getI18NString("service.gui.FILE_TOO_BIG",
@ -1476,7 +1478,7 @@ public void sendSmsMessage()
this.addMessage(
smsChatTransport.getName(),
System.currentTimeMillis(),
new Date(),
Chat.OUTGOING_MESSAGE,
messageText,
"plain/text");
@ -1570,7 +1572,7 @@ protected void sendInstantMessage()
this.addMessage(
chatSession.getCurrentChatTransport().getName(),
System.currentTimeMillis(),
new Date(),
Chat.OUTGOING_MESSAGE,
messageText,
mimeType);
@ -1595,7 +1597,7 @@ protected void sendInstantMessage()
this.addMessage(
chatSession.getCurrentChatTransport().getName(),
System.currentTimeMillis(),
new Date(),
Chat.OUTGOING_MESSAGE,
messageText,
mimeType);
@ -1724,13 +1726,13 @@ public void messageDelivered(MessageDeliveredEvent evt)
addMessage(
contact.getDisplayName(),
System.currentTimeMillis(),
new Date(),
Chat.OUTGOING_MESSAGE,
msg.getContent(), msg.getContentType());
addMessage(
contact.getDisplayName(),
System.currentTimeMillis(),
new Date(),
Chat.ACTION_MESSAGE,
GuiActivator.getResources().getI18NString(
"service.gui.SMS_SUCCESSFULLY_SENT"),
@ -1788,7 +1790,7 @@ else if (evt.getErrorCode()
addMessage(
metaContact.getDisplayName(),
System.currentTimeMillis(),
new Date(),
Chat.OUTGOING_MESSAGE,
sourceMessage.getContent(),
sourceMessage.getContentType());
@ -1806,7 +1808,7 @@ public void messageReceived(MessageReceivedEvent evt) {}
*
* @return the date of the first message in history for this chat.
*/
public long getFirstHistoryMsgTimestamp()
public Date getFirstHistoryMsgTimestamp()
{
return firstHistoryMsgTimestamp;
}
@ -1816,7 +1818,7 @@ public long getFirstHistoryMsgTimestamp()
*
* @return the date of the last message in history for this chat.
*/
public long getLastHistoryMsgTimestamp()
public Date getLastHistoryMsgTimestamp()
{
return lastHistoryMsgTimestamp;
}
@ -1992,7 +1994,7 @@ public void run()
// Show a status message to the user.
this.addMessage(
chatTransport.getName(),
System.currentTimeMillis(),
new Date(),
Chat.STATUS_MESSAGE,
GuiActivator.getResources().getI18NString(
"service.gui.STATUS_CHANGED_CHAT_MESSAGE",
@ -2183,7 +2185,7 @@ public void run()
this.addMessage(
chatContact.getName(),
System.currentTimeMillis(),
new Date(),
Chat.STATUS_MESSAGE,
statusMessage,
ChatHtmlUtils.TEXT_CONTENT_TYPE);
@ -2212,7 +2214,7 @@ else if (subject.equals(oldSubject))
this.addMessage(
chatSession.getChatName(),
System.currentTimeMillis(),
new Date(),
Chat.STATUS_MESSAGE,
GuiActivator.getResources().getI18NString(
"service.gui.CHAT_ROOM_SUBJECT_CHANGED",

@ -168,14 +168,14 @@ public List<ChatTransport> getTransportsForOperationSet(
*
* @return the start date of the history of this chat session.
*/
public abstract long getHistoryStartDate();
public abstract Date getHistoryStartDate();
/**
* Returns the end date of the history of this chat session.
*
* @return the end date of the history of this chat session.
*/
public abstract long getHistoryEndDate();
public abstract Date getHistoryEndDate();
/**
* Returns the default mobile number used to send sms-es in this session.

@ -139,7 +139,7 @@ public void run()
{
if(containsChat(chatPanel))
{
long lastMsgTimestamp = chatPanel.getChatConversationPanel()
Date lastMsgTimestamp = chatPanel.getChatConversationPanel()
.getLastIncomingMsgTimestamp();
if (!chatPanel.isWriteAreaEmpty())
@ -151,7 +151,7 @@ public void run()
if (answer == JOptionPane.OK_OPTION)
closeChatPanel(chatPanel);
}
else if (System.currentTimeMillis() - lastMsgTimestamp
else if (System.currentTimeMillis() - lastMsgTimestamp.getTime()
< 2 * 1000)
{
int answer = showWarningMessage(
@ -276,11 +276,12 @@ void closeAllChats(ChatContainer chatContainer, boolean warningEnabled)
(AdHocChatRoomWrapper) adHocSession.getDescriptor());
}
long lastMsgTimestamp = chatPanel.getChatConversationPanel()
Date lastMsgTimestamp = chatPanel.getChatConversationPanel()
.getLastIncomingMsgTimestamp();
if (!chatPanel.isWriteAreaEmpty()
|| chatPanel.containsActiveFileTransfers()
|| System.currentTimeMillis() - lastMsgTimestamp < 2 * 1000)
|| System.currentTimeMillis()
- lastMsgTimestamp.getTime() < 2 * 1000)
{
activePanel = chatPanel;
}
@ -292,7 +293,7 @@ void closeAllChats(ChatContainer chatContainer, boolean warningEnabled)
return;
}
long lastMsgTimestamp = activePanel.getChatConversationPanel()
Date lastMsgTimestamp = activePanel.getChatConversationPanel()
.getLastIncomingMsgTimestamp();
if (!activePanel.isWriteAreaEmpty())
@ -304,7 +305,8 @@ void closeAllChats(ChatContainer chatContainer, boolean warningEnabled)
if (answer == JOptionPane.OK_OPTION)
this.closeAllChats(chatContainer);
}
else if (System.currentTimeMillis() - lastMsgTimestamp < 2 * 1000)
else if (System.currentTimeMillis()
- lastMsgTimestamp.getTime() < 2 * 1000)
{
int answer = showWarningMessage(
"service.gui.CLOSE_CHAT_AFTER_NEW_MESSAGE",

@ -166,9 +166,9 @@ public Collection<Object> getHistoryAfterDate(Date date, int count)
*
* @return the start date of the history of this chat session.
*/
public long getHistoryStartDate()
public Date getHistoryStartDate()
{
long startHistoryDate = 0;
Date startHistoryDate = new Date(0);
MetaHistoryService metaHistory
= GuiActivator.getMetaHistoryService();
@ -218,9 +218,9 @@ else if (o instanceof FileRecord)
*
* @return the end date of the history of this chat session.
*/
public long getHistoryEndDate()
public Date getHistoryEndDate()
{
long endHistoryDate = 0;
Date endHistoryDate = new Date(0);
MetaHistoryService metaHistory
= GuiActivator.getMetaHistoryService();

@ -8,6 +8,7 @@
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
@ -132,7 +133,7 @@ private void sendSmsMessage(String phoneNumber, String message)
chatPanel.addMessage(
phoneNumber,
System.currentTimeMillis(),
new Date(),
Chat.OUTGOING_MESSAGE,
message,
"text/plain");
@ -150,7 +151,7 @@ private void sendSmsMessage(String phoneNumber, String message)
chatPanel.addMessage(
phoneNumber,
System.currentTimeMillis(),
new Date(),
Chat.OUTGOING_MESSAGE,
message,
"text/plain");

@ -203,7 +203,7 @@ public Collection<Object> getHistoryAfterDate(Date date, int count)
*
* @return the start date of the history of this chat session.
*/
public long getHistoryStartDate()
public Date getHistoryStartDate()
{
MetaHistoryService metaHistory
= GuiActivator.getMetaHistoryService();
@ -212,9 +212,9 @@ public long getHistoryStartDate()
// here. The history could be "disabled" from the user
// through one of the configuration forms.
if (metaHistory == null)
return 0;
return new Date(0);
long startHistoryDate = 0;
Date startHistoryDate = new Date(0);
Collection<Object> firstMessage = metaHistory
.findFirstMessagesAfter(
@ -252,7 +252,7 @@ else if(o instanceof MessageReceivedEvent)
*
* @return the end date of the history of this chat session.
*/
public long getHistoryEndDate()
public Date getHistoryEndDate()
{
MetaHistoryService metaHistory
= GuiActivator.getMetaHistoryService();
@ -261,9 +261,9 @@ public long getHistoryEndDate()
// here. The history could be "disabled" from the user
// through one of the configuration forms.
if (metaHistory == null)
return 0;
return new Date(0);
long endHistoryDate = 0;
Date endHistoryDate = new Date(0);
Collection<Object> lastMessage = metaHistory
.findLastMessagesBefore(

@ -241,11 +241,15 @@ public void messageReceived(ChatRoomMessageReceivedEvent evt)
if (evt.isHistoryMessage())
{
long timeStamp = chatPanel.getChatConversationPanel()
Date timeStamp = chatPanel.getChatConversationPanel()
.getLastIncomingMsgTimestamp();
Collection<Object> c =
chatPanel.getChatSession().getHistoryBeforeDate(
new Date(timeStamp == 0 ? System.currentTimeMillis() - 10000 : timeStamp), 20);
new Date(
timeStamp.equals(new Date(0))
? System.currentTimeMillis() - 10000
: timeStamp.getTime()
), 20);
if (c.size() > 0)
{
boolean isPresent = false;
@ -391,7 +395,7 @@ else if (evt.getErrorCode()
chatPanel.addMessage(
destMember.getName(),
System.currentTimeMillis(),
new Date(),
Chat.OUTGOING_MESSAGE,
sourceMessage.getContent(),
sourceMessage.getContentType());
@ -1928,7 +1932,7 @@ else if (evt.getErrorCode()
chatPanel.addMessage(
destParticipant.getDisplayName(),
System.currentTimeMillis(),
new Date(),
Chat.OUTGOING_MESSAGE,
sourceMessage.getContent(),
sourceMessage.getContentType());

@ -239,7 +239,7 @@ public Collection<Object> getHistoryAfterDate(Date date, int count)
*
* @return the start date of the history of this chat session.
*/
public long getHistoryStartDate()
public Date getHistoryStartDate()
{
MetaHistoryService metaHistory
= GuiActivator.getMetaHistoryService();
@ -248,9 +248,9 @@ public long getHistoryStartDate()
// here. The history could be "disabled" from the user
// through one of the configuration forms.
if (metaHistory == null)
return 0;
return new Date(0);
long startHistoryDate = 0;
Date startHistoryDate = new Date(0);
Collection<Object> firstMessage = metaHistory
.findFirstMessagesAfter(
@ -288,7 +288,7 @@ else if(o instanceof MessageReceivedEvent)
*
* @return the end date of the history of this chat session.
*/
public long getHistoryEndDate()
public Date getHistoryEndDate()
{
MetaHistoryService metaHistory
= GuiActivator.getMetaHistoryService();
@ -297,9 +297,9 @@ public long getHistoryEndDate()
// here. The history could be "disabled" from the user
// through one of the configuration forms.
if (metaHistory == null)
return 0;
return new Date(0);
long endHistoryDate = 0;
Date endHistoryDate = new Date(0);
Collection<Object> lastMessage = metaHistory
.findLastMessagesBefore(

@ -104,10 +104,10 @@ else if (fileRecord.getStatus().equals(FileRecord.REFUSED))
this.setCompletedDownloadFile(fileRecord.getFile());
long date = fileRecord.getDate();
Date date = fileRecord.getDate();
titleLabel.setText(
getDateString(new Date(date)) + titleString);
getDateString(date) + titleString);
fileLabel.setText(getFileLabel(fileRecord.getFile()));
}
@ -118,7 +118,7 @@ else if (fileRecord.getStatus().equals(FileRecord.REFUSED))
*/
public Date getDate()
{
return new Date(fileRecord.getDate());
return fileRecord.getDate();
}
/**

@ -506,7 +506,7 @@ else if(historyContact instanceof ChatRoomWrapper)
if (msgList != null)
for (Object o : msgList)
{
long date = 0;
Date date = new Date(0);
if (o instanceof MessageDeliveredEvent)
{
@ -540,7 +540,7 @@ else if (o instanceof FileRecord)
Iterator<Date> iterator = datesDisplayed.iterator();
while(iterator.hasNext())
{
long currDate = iterator.next().getTime();
Date currDate = iterator.next();
containsDate
= (GuiUtils.compareDatesOnly(date, currDate) == 0);
@ -550,7 +550,7 @@ else if (o instanceof FileRecord)
if(!containsDate)
{
datesDisplayed.add(new Date(date));
datesDisplayed.add(date);
}
}
@ -688,7 +688,7 @@ else if (historyContact instanceof ChatRoomWrapper)
if (msgList != null)
for (Object o : msgList)
{
long date = 0;
Date date = new Date(0);
if (o instanceof MessageDeliveredEvent)
{
@ -705,7 +705,7 @@ else if (o instanceof MessageReceivedEvent)
for(Date date1 : datesDisplayed)
{
if(Math.floor(date1.getTime()/milisecondsPerDay)
== Math.floor(date/milisecondsPerDay)
== Math.floor(date.getTime()/milisecondsPerDay)
&& !keywordDatesVector.contains(date1))
{
keywordDatesVector.add(date1);
@ -850,7 +850,7 @@ public void messageDeliveryFailed(MessageDeliveryFailedEvent evt) {}
* @param messageContentType the content type of the message
*/
private void processMessage(Contact contact,
long timestamp,
Date timestamp,
String messageType,
String messageContent,
String messageContentType)
@ -873,8 +873,7 @@ private void processMessage(Contact contact,
Date lastDate = datesPanel.getDate(lastDateIndex);
if(lastDate != null
&& GuiUtils.compareDatesOnly(
lastDate.getTime(), timestamp) == 0)
&& GuiUtils.compareDatesOnly(lastDate, timestamp) == 0)
{
HTMLDocument document = dateHistoryTable.get(lastDate);
@ -896,11 +895,12 @@ private void processMessage(Contact contact,
}
}
else if (lastDate == null
|| GuiUtils.compareDatesOnly(lastDate.getTime(), timestamp) < 0)
|| GuiUtils.compareDatesOnly(lastDate, timestamp) < 0)
{
long milisecondsPerDay = 24*60*60*1000;
Date date = new Date(timestamp - timestamp % milisecondsPerDay);
Date date = new Date(timestamp.getTime()
- timestamp.getTime() % milisecondsPerDay);
datesDisplayed.add(date);
if(!datesPanel.containsDate(date))

@ -547,8 +547,10 @@ public void changeHistoryButtonsState(ChatPanel chatPanel)
{
ChatConversationPanel convPanel = chatPanel.getChatConversationPanel();
long firstMsgInHistory = chatPanel.getFirstHistoryMsgTimestamp();
long lastMsgInHistory = chatPanel.getLastHistoryMsgTimestamp();
long firstMsgInHistory = chatPanel
.getFirstHistoryMsgTimestamp().getTime();
long lastMsgInHistory = chatPanel
.getLastHistoryMsgTimestamp().getTime();
Date firstMsgInPage = convPanel.getPageFirstMsgTimestamp();
Date lastMsgInPage = convPanel.getPageLastMsgTimestamp();

@ -275,7 +275,7 @@ private void messageReceived(final Contact protocolContact,
final MetaContact metaContact,
final Message message,
final int eventType,
final long timestamp,
final Date timestamp,
final String correctedMessageUID)
{
if(!SwingUtilities.isEventDispatchThread())
@ -440,7 +440,7 @@ else if (evt.getErrorCode()
chatPanel.addMessage(
sourceContact.getAddress(),
metaContact.getDisplayName(),
System.currentTimeMillis(),
new Date(),
Chat.OUTGOING_MESSAGE,
sourceMessage.getContent(),
sourceMessage.getContentType(),

@ -6,6 +6,10 @@
*/
package net.java.sip.communicator.impl.history;
import static
net.java.sip.communicator.service.history.HistoryService.DATE_FORMAT;
import java.text.*;
import java.util.*;
import java.util.regex.*;
@ -162,6 +166,7 @@ public synchronized QueryResultSet<HistoryRecord> findLast(int count) throws Run
int leftCount = count;
int currentFile = filelist.size() - 1;
SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
while(leftCount > 0 && currentFile >= 0)
{
Document doc = this.historyImpl.
@ -202,9 +207,17 @@ public synchronized QueryResultSet<HistoryRecord> findLast(int count) throws Run
NodeList propertyNodes = node.getChildNodes();
Date timestamp;
String ts = node.getAttributes().getNamedItem("timestamp")
.getNodeValue();
long timestamp = Long.parseLong(ts);
try
{
timestamp = sdf.parse(ts);
}
catch (ParseException e)
{
timestamp = new Date(Long.parseLong(ts));
}
ArrayList<String> nameVals = new ArrayList<String>();
@ -323,6 +336,7 @@ public QueryResultSet<HistoryRecord> findFirstRecordsAfter(Date date, int count)
int leftCount = count;
int currentFile = 0;
SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
while(leftCount > 0 && currentFile < filelist.size())
{
Document doc = this.historyImpl.
@ -343,9 +357,17 @@ public QueryResultSet<HistoryRecord> findFirstRecordsAfter(Date date, int count)
NodeList propertyNodes = node.getChildNodes();
Date timestamp;
String ts = node.getAttributes().getNamedItem("timestamp")
.getNodeValue();
long timestamp = Long.parseLong(ts);
try
{
timestamp = sdf.parse(ts);
}
catch (ParseException e)
{
timestamp = new Date(Long.parseLong(ts));
}
if(!isInPeriod(timestamp, date, null))
continue;
@ -418,6 +440,7 @@ public QueryResultSet<HistoryRecord> findLastRecordsBefore(Date date, int count)
int currentFile = filelist.size() - 1;
SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
while(leftCount > 0 && currentFile >= 0)
{
Document doc = this.historyImpl.
@ -437,9 +460,17 @@ public QueryResultSet<HistoryRecord> findLastRecordsBefore(Date date, int count)
node = nodes.item(i);
NodeList propertyNodes = node.getChildNodes();
Date timestamp;
String ts = node.getAttributes().getNamedItem("timestamp")
.getNodeValue();
long timestamp = Long.parseLong(ts);
try
{
timestamp = sdf.parse(ts);
}
catch (ParseException e)
{
timestamp = new Date(Long.parseLong(ts));
}
if(!isInPeriod(timestamp, null, date))
continue;
@ -516,6 +547,7 @@ private QueryResultSet<HistoryRecord> find(
fireProgressStateChanged(startDate, endDate,
keywords, HistorySearchProgressListener.PROGRESS_MINIMUM_VALUE);
SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
Iterator<String> fileIterator = filelist.iterator();
while (fileIterator.hasNext())
{
@ -538,9 +570,17 @@ private QueryResultSet<HistoryRecord> find(
{
node = nodes.item(i);
Date timestamp;
String ts = node.getAttributes().getNamedItem("timestamp")
.getNodeValue();
long timestamp = Long.parseLong(ts);
try
{
timestamp = sdf.parse(ts);
}
catch (ParseException e)
{
timestamp = new Date(Long.parseLong(ts));
}
if(isInPeriod(timestamp, startDate, endDate))
{
@ -582,23 +622,22 @@ private QueryResultSet<HistoryRecord> find(
* @param endDate Date the end of the period
* @return boolean
*/
static boolean isInPeriod(long timestamp, Date startDate, Date endDate)
static boolean isInPeriod(Date timestamp, Date startDate, Date endDate)
{
if(startDate == null)
{
if(endDate == null)
return true;
else
return timestamp < endDate.getTime();
return timestamp.before(endDate);
}
else
{
if(endDate == null)
return timestamp > startDate.getTime();
return timestamp.after(startDate);
else
return
timestamp > startDate.getTime()
&& timestamp < endDate.getTime();
timestamp.after(startDate) && timestamp.before(endDate);
}
}
@ -615,7 +654,7 @@ static boolean isInPeriod(long timestamp, Date startDate, Date endDate)
* @return HistoryRecord
*/
static HistoryRecord filterByKeyword( NodeList propertyNodes,
long timestamp,
Date timestamp,
String[] keywords,
String field,
boolean caseSensitive)
@ -945,14 +984,7 @@ private static class HistoryRecordComparator
{
public int compare(HistoryRecord h1, HistoryRecord h2)
{
long d = (h2.getTimestamp() - h1.getTimestamp());
if (d == 0)
return 0;
else if (d < 0)
return -1;
else
return 1;
return h1.getTimestamp().compareTo(h2.getTimestamp());
}
}
}

@ -6,8 +6,12 @@
*/
package net.java.sip.communicator.impl.history;
import static
net.java.sip.communicator.service.history.HistoryService.DATE_FORMAT;
import java.io.*;
import java.security.*;
import java.text.*;
import java.util.*;
import net.java.sip.communicator.service.history.*;
@ -65,12 +69,12 @@ public void addRecord(String[] propertyValues)
addRecord(
structPropertyNames,
propertyValues,
System.currentTimeMillis());
new Date());
}
public void addRecord(String[] propertyValues, Date timestamp)
throws IOException {
this.addRecord(structPropertyNames, propertyValues, timestamp.getTime());
this.addRecord(structPropertyNames, propertyValues, timestamp);
}
/**
@ -86,7 +90,7 @@ public void addRecord(String[] propertyValues, Date timestamp)
*/
private void addRecord(String[] propertyNames,
String[] propertyValues,
long date)
Date date)
throws InvalidParameterException, IOException
{
// Synchronized to assure that two concurrent threads can insert records
@ -106,7 +110,9 @@ private void addRecord(String[] propertyNames,
synchronized (root)
{
Element elem = this.currentDoc.createElement("record");
elem.setAttribute("timestamp", Long.toString(date));
SimpleDateFormat sdf
= new SimpleDateFormat(DATE_FORMAT);
elem.setAttribute("timestamp", sdf.format(date));
for (int i = 0; i < propertyNames.length; i++)
{
@ -166,7 +172,7 @@ private void addRecord(String[] propertyNames,
* @param date Date
* @param loadLastFile boolean
*/
private void createNewDoc(long date, boolean loadLastFile)
private void createNewDoc(Date date, boolean loadLastFile)
{
boolean loaded = false;
@ -197,11 +203,7 @@ private void createNewDoc(long date, boolean loadLastFile)
if (!loaded)
{
this.currentFile = Long.toString(date);
// while (this.currentFile.length() < 8)
// {
// this.currentFile = "0" + this.currentFile;
// }
this.currentFile = Long.toString(date.getTime());
this.currentFile += ".xml";
this.currentDoc = this.historyImpl.createDocument(this.currentFile);

@ -6,6 +6,10 @@
*/
package net.java.sip.communicator.impl.history;
import static
net.java.sip.communicator.service.history.HistoryService.DATE_FORMAT;
import java.text.*;
import java.util.*;
import net.java.sip.communicator.service.history.*;
@ -140,6 +144,7 @@ private void find( Date startDate,
startDate, endDate, true);
Iterator<String> fileIterator = filelist.iterator();
SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
while (fileIterator.hasNext() && resultCount > 0 && !query.isCanceled())
{
String filename = fileIterator.next();
@ -155,9 +160,17 @@ private void find( Date startDate,
i--)
{
Node node = nodes.item(i);
Date timestamp;
String ts = node.getAttributes().getNamedItem("timestamp")
.getNodeValue();
long timestamp = Long.parseLong(ts);
try
{
timestamp = sdf.parse(ts);
}
catch (ParseException e)
{
timestamp = new Date(Long.parseLong(ts));
}
if(HistoryReaderImpl.isInPeriod(timestamp, startDate, endDate))
{

@ -889,9 +889,9 @@ public void stop(BundleContext bc)
private static class RecordsComparator
implements Comparator<Object>
{
private long getDate(Object o)
private Date getDate(Object o)
{
long date = 0;
Date date = new Date(0);
if(o instanceof MessageDeliveredEvent)
date = ((MessageDeliveredEvent)o).getTimestamp();
else if(o instanceof MessageReceivedEvent)
@ -901,7 +901,7 @@ else if(o instanceof ChatRoomMessageDeliveredEvent)
else if(o instanceof ChatRoomMessageReceivedEvent)
date = ((ChatRoomMessageReceivedEvent)o).getTimestamp();
else if(o instanceof CallRecord)
date = ((CallRecord)o).getStartTime().getTime();
date = ((CallRecord)o).getStartTime();
else if(o instanceof FileRecord)
date = ((FileRecord)o).getDate();
@ -909,10 +909,10 @@ else if(o instanceof FileRecord)
}
public int compare(Object o1, Object o2)
{
long date1 = getDate(o1);
long date2 = getDate(o2);
Date date1 = getDate(o1);
Date date2 = getDate(o2);
return (date1 < date2) ? -1 : ((date1 == date2) ? 0 : 1);
return date1.compareTo(date2);
}
}

@ -6,8 +6,12 @@
*/
package net.java.sip.communicator.impl.msghistory;
import static
net.java.sip.communicator.service.history.HistoryService.DATE_FORMAT;
import java.beans.*;
import java.io.*;
import java.text.*;
import java.util.*;
import net.java.sip.communicator.service.contactlist.*;
@ -387,13 +391,13 @@ public Collection<EventObject> findFirstMessagesAfter( MetaContact contact,
if(object instanceof MessageDeliveredEvent)
{
isRecordOK =
(((MessageDeliveredEvent)object).getTimestamp()
(((MessageDeliveredEvent)object).getTimestamp().getTime()
> date.getTime());
}
else if(object instanceof MessageReceivedEvent)
{
isRecordOK =
(((MessageReceivedEvent)object).getTimestamp()
(((MessageReceivedEvent)object).getTimestamp().getTime()
> date.getTime());
}
@ -630,18 +634,19 @@ private EventObject convertHistoryRecordToMessageEvent( HistoryRecord hr,
Contact contact)
{
MessageImpl msg = createMessageFromHistoryRecord(hr);
long timestamp;
Date timestamp;
// if there is value for date of receiving the message
// this is the event timestamp (this is the date that had came
// from protocol)
// the HistoryRecord timestamp is the timestamp when the record
// was written
long messageReceivedDate = msg.getMessageReceivedDate();
long hrTimestamp = hr.getTimestamp();
if (messageReceivedDate != 0)
Date messageReceivedDate = msg.getMessageReceivedDate();
Date hrTimestamp = hr.getTimestamp();
if (messageReceivedDate.getTime() != 0)
{
if(messageReceivedDate - hrTimestamp > 86400000) // 24*60*60*1000
// 24*60*60*1000
if(messageReceivedDate.getTime() - hrTimestamp.getTime() > 86400000)
timestamp = hrTimestamp;
else
timestamp = msg.getMessageReceivedDate();
@ -676,18 +681,19 @@ private EventObject convertHistoryRecordToMessageEvent(
HistoryRecord hr, ChatRoom room)
{
MessageImpl msg = createMessageFromHistoryRecord(hr);
long timestamp;
Date timestamp;
// if there is value for date of receiving the message
// this is the event timestamp (this is the date that had came
// from protocol)
// the HistoryRecord timestamp is the timestamp when the record
// was written
long messageReceivedDate = msg.getMessageReceivedDate();
long hrTimestamp = hr.getTimestamp();
if(messageReceivedDate != 0)
Date messageReceivedDate = msg.getMessageReceivedDate();
Date hrTimestamp = hr.getTimestamp();
if(messageReceivedDate.getTime() != 0)
{
if(messageReceivedDate - hrTimestamp > 86400000) // 24*60*60*1000
// 24*60*60*1000
if(messageReceivedDate.getTime() - hrTimestamp.getTime() > 86400000)
timestamp = hrTimestamp;
else
timestamp = msg.getMessageReceivedDate();
@ -735,7 +741,8 @@ private MessageImpl createMessageFromHistoryRecord(HistoryRecord hr)
String messageUID = null;
String subject = null;
boolean isOutgoing = false;
long messageReceivedDate = 0;
Date messageReceivedDate = new Date(0);
SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
for (int i = 0; i < hr.getPropertyNames().length; i++)
{
String propName = hr.getPropertyNames()[i];
@ -759,8 +766,15 @@ else if (hr.getPropertyValues()[i].equals("out"))
}
else if (propName.equals(STRUCTURE_NAMES[6]))
{
messageReceivedDate =
Long.parseLong(hr.getPropertyValues()[i]);
try
{
messageReceivedDate = sdf.parse(hr.getPropertyValues()[i]);
}
catch (ParseException e)
{
messageReceivedDate =
new Date(Long.parseLong(hr.getPropertyValues()[i]));
}
}
}
return new MessageImpl(textContent, contentType, contentEncoding,
@ -892,7 +906,7 @@ public void messageDeliveryFailed(ChatRoomMessageDeliveryFailedEvent evt)
* that came from the protocol provider
*/
private void writeMessage(String direction, Contact source,
Contact destination, Message message, long messageTimestamp)
Contact destination, Message message, Date messageTimestamp)
{
try {
History history = this.getHistory(source, destination);
@ -913,14 +927,16 @@ private void writeMessage(String direction, Contact source,
* that came from the protocol provider
*/
private void writeMessage(History history, String direction,
Message message, long messageTimestamp)
Message message, Date messageTimestamp)
{
try {
HistoryWriter historyWriter = history.getWriter();
SimpleDateFormat sdf
= new SimpleDateFormat(HistoryService.DATE_FORMAT);
historyWriter.addRecord(new String[] { direction,
message.getContent(), message.getContentType(),
message.getEncoding(), message.getMessageUID(),
message.getSubject(), String.valueOf(messageTimestamp) },
message.getSubject(), sdf.format(messageTimestamp) },
new Date()); // this date is when the history record is written
} catch (IOException e)
{
@ -939,7 +955,7 @@ private void writeMessage(History history, String direction,
*/
private void writeMessage(History history, String direction,
ChatRoomMember from,
Message message, long messageTimestamp)
Message message, Date messageTimestamp)
{
try {
// mising from, strange messages, most probably a history
@ -948,11 +964,13 @@ private void writeMessage(History history, String direction,
return;
HistoryWriter historyWriter = history.getWriter();
SimpleDateFormat sdf
= new SimpleDateFormat(HistoryService.DATE_FORMAT);
historyWriter.addRecord(new String[] { direction,
message.getContent(), message.getContentType(),
message.getEncoding(), message.getMessageUID(),
from.getContactAddress(),
String.valueOf(messageTimestamp) },
sdf.format(messageTimestamp) },
new Date()); // this date is when the history record is written
} catch (IOException e)
{
@ -971,16 +989,18 @@ private void writeMessage(History history, String direction,
*/
private void writeMessage(History history, String direction,
Contact from,
Message message, long messageTimestamp)
Message message, Date messageTimestamp)
{
try
{
HistoryWriter historyWriter = history.getWriter();
SimpleDateFormat sdf
= new SimpleDateFormat(HistoryService.DATE_FORMAT);
historyWriter.addRecord(new String[] { direction,
message.getContent(), message.getContentType(),
message.getEncoding(), message.getMessageUID(),
from.getAddress(),
String.valueOf(messageTimestamp) },
sdf.format(messageTimestamp) },
new Date()); // this date is when the history record is written
} catch (IOException e)
{
@ -1948,11 +1968,11 @@ private static class MessageImpl
{
private final boolean isOutgoing;
private final long messageReceivedDate;
private final Date messageReceivedDate;
MessageImpl(String content, String contentType, String encoding,
String subject, String messageUID, boolean isOutgoing,
long messageReceivedDate)
Date messageReceivedDate)
{
super(content, contentType, encoding, subject, messageUID);
@ -1960,7 +1980,7 @@ private static class MessageImpl
this.messageReceivedDate = messageReceivedDate;
}
public long getMessageReceivedDate()
public Date getMessageReceivedDate()
{
return messageReceivedDate;
}
@ -1975,8 +1995,8 @@ private static class MessageEventComparator<T>
{
public int compare(T o1, T o2)
{
long date1;
long date2;
Date date1;
Date date2;
if(o1 instanceof MessageDeliveredEvent)
date1 = ((MessageDeliveredEvent)o1).getTimestamp();
@ -1992,7 +2012,7 @@ else if(o2 instanceof MessageReceivedEvent)
else
return 0;
return (date1 < date2) ? -1 : ((date1 == date2) ? 0 : 1);
return date1.compareTo(date2);
}
}
@ -2006,8 +2026,8 @@ private static class ChatRoomMessageEventComparator<T>
{
public int compare(T o1, T o2)
{
long date1;
long date2;
Date date1;
Date date2;
if(o1 instanceof ChatRoomMessageDeliveredEvent)
date1 = ((ChatRoomMessageDeliveredEvent)o1).getTimestamp();
@ -2023,7 +2043,7 @@ else if(o2 instanceof ChatRoomMessageReceivedEvent)
else
return 0;
return (date1 < date2) ? -1 : ((date1 == date2) ? 0 : 1);
return date1.compareTo(date2);
}
}

@ -433,7 +433,7 @@ public void sendMessage(Message message) throws OperationFailedException
AdHocChatRoomMessageDeliveredEvent msgDeliveredEvt =
new AdHocChatRoomMessageDeliveredEvent(
this,
System.currentTimeMillis(),
new Date(),
message,
AdHocChatRoomMessageDeliveredEvent.CONVERSATION_MESSAGE_DELIVERED);
@ -594,7 +594,7 @@ public void handleIncomingMessage(ChatRoomSession chatRoomSession,
new AdHocChatRoomMessageReceivedEvent(
chatRoom,
participants.get(participantUID),
System.currentTimeMillis(),
new Date(),
newMessage,
AdHocChatRoomMessageReceivedEvent
.CONVERSATION_MESSAGE_RECEIVED);

@ -70,15 +70,6 @@ public class OperationSetBasicInstantMessagingIcqImpl
*/
private static final int MAX_MSG_LEN = 2047;
/**
* I do not why but we sometimes receive messages with a date in the future.sdf
* I've decided to ignore such messages. I draw the line on
* currentTimeMillis() + ONE_DAY milliseconds. Anything with a date farther
* in the future is considered bogus and its date is replaced with current
* time millis.
*/
private static final long ONE_DAY = 86400001;
/**
* KeepAlive interval for sending packets
*/
@ -270,10 +261,13 @@ public void handleResponse(SnacResponseEvent evt)
//reason that I currently don't know. Until we find it
//(which may well be never) we are putting in an agly hack
//ignoring messages with a date beyond tomorrow.
long current = System.currentTimeMillis();
long msgDate = offlineMsgCmd.getDate().getTime();
Date current = new Date();
Date msgDate = offlineMsgCmd.getDate();
if( (current + ONE_DAY) > msgDate )
Calendar tomorrow = new GregorianCalendar();
tomorrow.setTime(current);
tomorrow.set(Calendar.DATE, tomorrow.get(Calendar.DATE) + 1);
if( tomorrow.after(msgDate) )
msgDate = current;
MessageReceivedEvent msgReceivedEvt
@ -557,10 +551,13 @@ public void gotMessage(Conversation conversation, MessageInfo minfo)
//reason that I currently don't know. Until we find it
//(which may well be never) we are putting in an agly hack
//ignoring messages with a date beyond tomorrow.
long current = System.currentTimeMillis();
long msgDate = minfo.getTimestamp().getTime();
Date current = new Date();
Date msgDate = minfo.getTimestamp();
if ( (current + ONE_DAY) > msgDate)
Calendar tomorrow = new GregorianCalendar();
tomorrow.setTime(current);
tomorrow.set(Calendar.DATE, tomorrow.get(Calendar.DATE) + 1);
if ( tomorrow.after(msgDate))
msgDate = current;

@ -809,7 +809,7 @@ private void fireMessageDeliveredEvent(Message message)
ChatRoomMessageDeliveredEvent msgDeliveredEvt
= new ChatRoomMessageDeliveredEvent(this,
System.currentTimeMillis(),
new Date(),
msg,
eventType);
@ -838,7 +838,7 @@ private void fireMessageDeliveredEvent(Message message)
*/
public void fireMessageReceivedEvent( Message message,
ChatRoomMember fromMember,
long date,
Date date,
int eventType)
{
ChatRoomMessageReceivedEvent event

@ -241,7 +241,7 @@ protected void onMessage( String channel,
chatRoom.fireMessageReceivedEvent(
message,
sourceMember,
System.currentTimeMillis(),
new Date(),
ChatRoomMessageReceivedEvent.CONVERSATION_MESSAGE_RECEIVED);
}
@ -297,7 +297,7 @@ protected void onPrivateMessage(String sender,
chatRoom.fireMessageReceivedEvent(
message,
sourceMember,
System.currentTimeMillis(),
new Date(),
ChatRoomMessageReceivedEvent.CONVERSATION_MESSAGE_RECEIVED);
}
@ -345,7 +345,7 @@ protected void onAction(String sender,
chatRoom.fireMessageReceivedEvent(
actionMessage,
sourceMember,
System.currentTimeMillis(),
new Date(),
ChatRoomMessageReceivedEvent.ACTION_MESSAGE_RECEIVED);
}
@ -666,7 +666,7 @@ protected void onNotice(String sourceNick,
chatRoom.fireMessageReceivedEvent(
message,
sourceMember,
System.currentTimeMillis(),
new Date(),
ChatRoomMessageReceivedEvent.ACTION_MESSAGE_RECEIVED);
}
@ -1251,7 +1251,7 @@ else if (code != RPL_LISTSTART
serverRoom.fireMessageReceivedEvent(
message,
serverMember,
System.currentTimeMillis(),
new Date(),
ChatRoomMessageReceivedEvent.SYSTEM_MESSAGE_RECEIVED);
}
}
@ -1830,7 +1830,7 @@ private void onWhoIs(UserInfo userInfo)
chatRoom.fireMessageReceivedEvent(
message,
ircMUCOpSet.findSystemMember(),
System.currentTimeMillis(),
new Date(),
ChatRoomMessageReceivedEvent.SYSTEM_MESSAGE_RECEIVED);
}
@ -2057,7 +2057,7 @@ protected void createPrivateChatRoom(String target)
privateChatRoom.fireMessageReceivedEvent(
queryMessage,
sourceMember,
System.currentTimeMillis(),
new Date(),
ChatRoomMessageReceivedEvent.SYSTEM_MESSAGE_RECEIVED);
}
}

@ -765,7 +765,7 @@ public void sendMessage(Message message)
ChatRoomMessageDeliveredEvent msgDeliveredEvt
= new ChatRoomMessageDeliveredEvent(
this,
System.currentTimeMillis(),
new Date(),
message,
ChatRoomMessageDeliveredEvent
.CONVERSATION_MESSAGE_DELIVERED);
@ -1587,18 +1587,18 @@ public void processPacket(Packet packet)
org.jivesoftware.smack.packet.Message msg
= (org.jivesoftware.smack.packet.Message) packet;
long timeStamp;
Date timeStamp;
DelayInformation delay =
(DelayInformation)msg.getExtension("x", "jabber:x:delay");
if(delay != null)
{
timeStamp = delay.getStamp().getTime();
timeStamp = delay.getStamp();
}
else
{
timeStamp = System.currentTimeMillis();
timeStamp = new Date();
}
String msgBody = msg.getBody();
@ -2376,7 +2376,7 @@ public void processPacket(Packet packet)
= new ChatRoomMessageReceivedEvent(
ChatRoomJabberImpl.this,
member,
System.currentTimeMillis(),
new Date(),
createMessage(msgBody),
messageReceivedEventType);

@ -751,18 +751,18 @@ public void processPacket(Packet packet)
.createVolatileContact(fromUserID);
}
long timestamp = System.currentTimeMillis();
Date timestamp = new Date();
//Check for XEP-0091 timestamp (deprecated)
PacketExtension delay = msg.getExtension("x", "jabber:x:delay");
if(delay != null && delay instanceof DelayInformation)
{
timestamp = ((DelayInformation)delay).getStamp().getTime();
timestamp = ((DelayInformation)delay).getStamp();
}
//check for XEP-0203 timestamp
delay = msg.getExtension("delay", "urn:xmpp:delay");
if(delay != null && delay instanceof DelayInfo)
{
timestamp = ((DelayInfo)delay).getStamp().getTime();
timestamp = ((DelayInfo)delay).getStamp();
}
MessageReceivedEvent msgReceivedEvt = new MessageReceivedEvent(
newMessage, sourceContact, timestamp, correctedMessageUID);
@ -979,7 +979,7 @@ public void processPacket(Packet packet)
newMail, HTML_MIME_TYPE, DEFAULT_MIME_ENCODING, null);
MessageReceivedEvent msgReceivedEvt = new MessageReceivedEvent(
newMailMessage, sourceContact, System.currentTimeMillis(),
newMailMessage, sourceContact, new Date(),
MessageReceivedEvent.SYSTEM_MESSAGE_RECEIVED);
fireMessageEvent(msgReceivedEvt);

@ -6,6 +6,8 @@
*/
package net.java.sip.communicator.impl.protocol.mock;
import java.util.*;
import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.service.protocol.event.*;
@ -67,7 +69,7 @@ public void sendInstantMessage(Contact to, Message message)
IllegalArgumentException
{
fireMessageEvent(
new MessageDeliveredEvent(message, to, System.currentTimeMillis()));
new MessageDeliveredEvent(message, to, new Date()));
}
/**
@ -113,6 +115,6 @@ public void deliverMessage(String to, Message msg)
fireMessageEvent(
new MessageReceivedEvent(
msg, sourceContact, System.currentTimeMillis()));
msg, sourceContact, new Date()));
}
}

@ -459,7 +459,7 @@ public void sendMessage(Message message)
ChatRoomMessageDeliveredEvent evt =
new ChatRoomMessageDeliveredEvent(
this,
System.currentTimeMillis(),
new Date(),
message,
ChatRoomMessageDeliveredEvent
.CONVERSATION_MESSAGE_DELIVERED);
@ -517,7 +517,7 @@ public void deliverMessage(Message msg, String from)
new ChatRoomMessageReceivedEvent(
this,
fromMember,
System.currentTimeMillis(),
new Date(),
msg,
ChatRoomMessageReceivedEvent
.CONVERSATION_MESSAGE_RECEIVED);

@ -411,7 +411,7 @@ public void sendMessage(Message message) throws OperationFailedException
AdHocChatRoomMessageDeliveredEvent msgDeliveredEvt
= new AdHocChatRoomMessageDeliveredEvent(
this,
System.currentTimeMillis(),
new Date(),
message,
AdHocChatRoomMessageDeliveredEvent.CONVERSATION_MESSAGE_DELIVERED);

@ -483,7 +483,7 @@ public void instantMessageReceived( MsnSwitchboard switchboard,
new AdHocChatRoomMessageReceivedEvent(
chatRoom,
participant,
System.currentTimeMillis(),
new Date(),
newMessage,
AdHocChatRoomMessageReceivedEvent
.CONVERSATION_MESSAGE_RECEIVED);

@ -244,7 +244,7 @@ public void instantMessageReceived(MsnSwitchboard switchboard,
MessageReceivedEvent msgReceivedEvt
= new MessageReceivedEvent(
newMessage, sourceContact , System.currentTimeMillis() );
newMessage, sourceContact , new Date());
// msgReceivedEvt = messageReceivedTransform(msgReceivedEvt);
@ -283,7 +283,7 @@ public void offlineMessageReceived(String body,
MessageReceivedEvent msgReceivedEvt
= new MessageReceivedEvent(
newMessage, sourceContact , System.currentTimeMillis() );
newMessage, sourceContact , new Date());
fireMessageEvent(msgReceivedEvt);
}
@ -366,7 +366,7 @@ public void newEmailNotificationReceived(MsnSwitchboard switchboard,
= new MessageReceivedEvent(
newMailMessage,
sourceContact,
System.currentTimeMillis(),
new Date(),
MessageReceivedEvent.SYSTEM_MESSAGE_RECEIVED);
fireMessageEvent(msgReceivedEvt);

@ -186,7 +186,7 @@ private void submitRssQuery(ContactRssImpl rssContact,
new MessageReceivedEvent(
createMessage(news),
rssContact,
System.currentTimeMillis()));
new Date()));
}
else if(userRequestedUpdate)
{
@ -195,7 +195,7 @@ else if(userRequestedUpdate)
new MessageReceivedEvent(
createMessage(news),
rssContact,
System.currentTimeMillis()));
new Date()));
}
}
@ -305,7 +305,7 @@ public void sendInstantMessage(Contact to, Message message)
DEFAULT_MIME_TYPE, DEFAULT_MIME_ENCODING, null);
fireMessageEvent(
new MessageDeliveredEvent(msg, to, System.currentTimeMillis()));
new MessageDeliveredEvent(msg, to, new Date()));
threadedContactFeedUpdate((ContactRssImpl)to);
}

@ -745,7 +745,7 @@ public boolean processRequest(RequestEvent requestEvent)
// fire an event
MessageReceivedEvent msgReceivedEvt
= new MessageReceivedEvent(
newMessage, from, System.currentTimeMillis());
newMessage, from, new Date());
fireMessageEvent(msgReceivedEvt);
return true;
@ -906,7 +906,7 @@ else if (status >= 200)
// we delivered the message
MessageDeliveredEvent msgDeliveredEvt
= new MessageDeliveredEvent(
newMessage, to, System.currentTimeMillis());
newMessage, to, new Date());
fireMessageEvent(msgDeliveredEvt);

@ -13,6 +13,7 @@
package net.java.sip.communicator.impl.protocol.ssh;
import java.io.*;
import java.util.*;
import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.service.protocol.event.*;
@ -273,7 +274,7 @@ protected void fireMessageReceived(Message message, Contact from)
new MessageReceivedEvent(
message,
from,
System.currentTimeMillis(),
new Date(),
((ContactSSH) from).getMessageType()));
}

@ -378,7 +378,7 @@ public void sendMessage(Message message) throws OperationFailedException
AdHocChatRoomMessageDeliveredEvent msgDeliveredEvt
= new AdHocChatRoomMessageDeliveredEvent(
this,
System.currentTimeMillis(),
new Date(),
message,
ChatRoomMessageDeliveredEvent.CONVERSATION_MESSAGE_DELIVERED);

@ -666,7 +666,7 @@ public void conferenceMessageReceived(SessionConferenceEvent ev)
new AdHocChatRoomMessageReceivedEvent(
chatRoom,
member,
System.currentTimeMillis(),
new Date(),
newMessage,
AdHocChatRoomMessageReceivedEvent
.CONVERSATION_MESSAGE_RECEIVED);

@ -152,7 +152,7 @@ public void sendInstantMessage(Contact to, Message message)
MessageDeliveredEvent msgDeliveryPendingEvt
= new MessageDeliveredEvent(
message, to, System.currentTimeMillis());
message, to, new Date());
msgDeliveryPendingEvt = messageDeliveryPendingTransform(msgDeliveryPendingEvt);
@ -192,7 +192,7 @@ public void sendInstantMessage(Contact to, Message message)
MessageDeliveredEvent msgDeliveredEvt
= new MessageDeliveredEvent(
message, to, System.currentTimeMillis());
message, to, new Date());
// msgDeliveredEvt = messageDeliveredTransform(msgDeliveredEvt);
@ -402,7 +402,7 @@ public void newMailReceived(SessionNewMailEvent ev)
}
MessageReceivedEvent msgReceivedEvt
= new MessageReceivedEvent(
newMailMessage, sourceContact, System.currentTimeMillis(),
newMailMessage, sourceContact, new Date(),
MessageReceivedEvent.SYSTEM_MESSAGE_RECEIVED);
fireMessageEvent(msgReceivedEvt);
@ -455,7 +455,7 @@ private void handleNewMessage(SessionEvent ev)
MessageReceivedEvent msgReceivedEvt
= new MessageReceivedEvent(
newMessage, sourceContact , System.currentTimeMillis() );
newMessage, sourceContact , new Date());
// msgReceivedEvt = messageReceivedTransform(msgReceivedEvt);

@ -101,7 +101,7 @@ public void showWarning(SessionID sessionID, String warn)
return;
OtrActivator.uiService.getChat(contact).addMessage(
contact.getDisplayName(), System.currentTimeMillis(),
contact.getDisplayName(), new Date(),
Chat.SYSTEM_MESSAGE, warn,
OperationSetBasicInstantMessaging.DEFAULT_MIME_TYPE);
}
@ -137,7 +137,7 @@ public void showError(SessionID sessionID, String err)
return;
OtrActivator.uiService.getChat(contact).addMessage(
contact.getDisplayName(), System.currentTimeMillis(),
contact.getDisplayName(), new Date(),
Chat.ERROR_MESSAGE, err,
OperationSetBasicInstantMessaging.DEFAULT_MIME_TYPE);
}
@ -194,7 +194,7 @@ public void sessionStatusChanged(SessionID sessionID)
});
OtrActivator.uiService.getChat(contact).addMessage(
contact.getDisplayName(),
System.currentTimeMillis(), Chat.SYSTEM_MESSAGE,
new Date(), Chat.SYSTEM_MESSAGE,
unverifiedSessionWarning,
OperationSetBasicInstantMessaging.HTML_MIME_TYPE);
@ -225,7 +225,7 @@ public void sessionStatusChanged(SessionID sessionID)
}
OtrActivator.uiService.getChat(contact).addMessage(
contact.getDisplayName(), System.currentTimeMillis(),
contact.getDisplayName(), new Date(),
Chat.SYSTEM_MESSAGE, message,
OperationSetBasicInstantMessaging.HTML_MIME_TYPE);

@ -7,6 +7,7 @@
package net.java.sip.communicator.service.filehistory;
import java.io.*;
import java.util.*;
import net.java.sip.communicator.service.protocol.*;
@ -50,7 +51,7 @@ public class FileRecord
private String direction = null;
private long date;
private Date date;
private File file = null;
private String status;
@ -73,7 +74,7 @@ public FileRecord(
String id,
Contact contact,
String direction,
long date,
Date date,
File file,
String status)
{
@ -98,7 +99,7 @@ public String getDirection()
* The date of the record.
* @return the date
*/
public long getDate()
public Date getDate()
{
return date;
}

@ -7,6 +7,7 @@
package net.java.sip.communicator.service.gui;
import java.awt.event.*;
import java.util.*;
import javax.swing.event.*;
import javax.swing.text.*;
@ -194,7 +195,7 @@ public interface Chat
* @param message the message text
* @param contentType the content type
*/
public void addMessage(String contactName, long date, String messageType,
public void addMessage(String contactName, Date date, String messageType,
String message, String contentType);
/**

@ -30,6 +30,11 @@ public interface HistoryService {
public static String CACHE_ENABLED_PROPERTY =
"net.java.sip.communicator.service.history.CACHE_ENABLED";
/**
* Date format used in the XML history database.
*/
public static final String DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSSZ";
/**
* Returns the IDs of all existing histories.
*

@ -6,12 +6,14 @@
*/
package net.java.sip.communicator.service.history.records;
import java.util.*;
/**
* @author Alexander Pelov
*/
public class HistoryRecord
{
private final long timestamp;
private final Date timestamp;
private final String[] propertyNames;
private final String[] propertyValues;
@ -29,7 +31,7 @@ public HistoryRecord(HistoryRecordStructure entryStructure,
this(
entryStructure.getPropertyNames(),
propertyValues,
System.currentTimeMillis());
new Date());
}
/**
@ -41,7 +43,7 @@ public HistoryRecord(HistoryRecordStructure entryStructure,
*/
public HistoryRecord(String[] propertyNames, String[] propertyValues)
{
this(propertyNames, propertyValues, System.currentTimeMillis());
this(propertyNames, propertyValues, new Date());
}
/**
@ -54,7 +56,7 @@ public HistoryRecord(String[] propertyNames, String[] propertyValues)
*/
public HistoryRecord(HistoryRecordStructure entryStructure,
String[] propertyValues,
long timestamp)
Date timestamp)
{
this(entryStructure.getPropertyNames(), propertyValues, timestamp);
}
@ -69,7 +71,7 @@ public HistoryRecord(HistoryRecordStructure entryStructure,
*/
public HistoryRecord(String[] propertyNames,
String[] propertyValues,
long timestamp)
Date timestamp)
{
// TODO: Validate: Assert.assertNonNull(propertyNames, "The property names should be non-null.");
// TODO: Validate: Assert.assertNonNull(propertyValues, "The property values should be non-null.");
@ -93,7 +95,7 @@ public String[] getPropertyValues()
return this.propertyValues;
}
public long getTimestamp()
public Date getTimestamp()
{
return this.timestamp;
}

@ -120,7 +120,7 @@ public abstract Message createMessage(
protected void fireMessageDelivered(Message message, Contact to)
{
fireMessageEvent(
new MessageDeliveredEvent(message, to, System.currentTimeMillis()));
new MessageDeliveredEvent(message, to, new Date()));
}
protected void fireMessageDeliveryFailed(
@ -224,7 +224,7 @@ else if (evt instanceof MessageDeliveryFailedEvent)
protected void fireMessageReceived(Message message, Contact from)
{
fireMessageEvent(
new MessageReceivedEvent(message, from, System.currentTimeMillis()));
new MessageReceivedEvent(message, from, new Date()));
}
/**

@ -39,7 +39,7 @@ public class AdHocChatRoomMessageDeliveredEvent
/**
* A timestamp indicating the exact date when the event occurred.
*/
private final long timestamp;
private final Date timestamp;
/**
* The received <tt>Message</tt>.
@ -63,7 +63,7 @@ public class AdHocChatRoomMessageDeliveredEvent
* either an ACTION_MESSAGE_DELIVERED or a CONVERSATION_MESSAGE_DELIVERED.
*/
public AdHocChatRoomMessageDeliveredEvent( AdHocChatRoom source,
long timestamp,
Date timestamp,
Message message,
int eventType)
{
@ -89,7 +89,7 @@ public Message getMessage()
*
* @return a Date indicating when the event occurred.
*/
public long getTimestamp()
public Date getTimestamp()
{
return this.timestamp;
}

@ -52,7 +52,7 @@ public class AdHocChatRoomMessageReceivedEvent
/**
* A timestamp indicating the exact date when the event occurred.
*/
private final long timestamp;
private final Date timestamp;
/**
* The received <tt>Message</tt>.
@ -79,7 +79,7 @@ public class AdHocChatRoomMessageReceivedEvent
*/
public AdHocChatRoomMessageReceivedEvent(AdHocChatRoom source,
Contact from,
long timestamp,
Date timestamp,
Message message,
int eventType)
{
@ -116,7 +116,7 @@ public Message getMessage()
* A timestamp indicating the exact date when the event occurred.
* @return a Date indicating when the event occurred.
*/
public long getTimestamp()
public Date getTimestamp()
{
return timestamp;
}

@ -44,7 +44,7 @@ public class ChatRoomMessageDeliveredEvent
/**
* A timestamp indicating the exact date when the event occurred.
*/
private final long timestamp;
private final Date timestamp;
/**
* The received <tt>Message</tt>.
@ -68,7 +68,7 @@ public class ChatRoomMessageDeliveredEvent
* either an ACTION_MESSAGE_DELIVERED or a CONVERSATION_MESSAGE_DELIVERED.
*/
public ChatRoomMessageDeliveredEvent(ChatRoom source,
long timestamp,
Date timestamp,
Message message,
int eventType)
{
@ -92,7 +92,7 @@ public Message getMessage()
* A timestamp indicating the exact date when the event occurred.
* @return a Date indicating when the event occurred.
*/
public long getTimestamp()
public Date getTimestamp()
{
return timestamp;
}

@ -56,7 +56,7 @@ public class ChatRoomMessageReceivedEvent
/**
* A timestamp indicating the exact date when the event occurred.
*/
private final long timestamp;
private final Date timestamp;
/**
* The received <tt>Message</tt>.
@ -87,7 +87,7 @@ public class ChatRoomMessageReceivedEvent
*/
public ChatRoomMessageReceivedEvent(ChatRoom source,
ChatRoomMember from,
long timestamp,
Date timestamp,
Message message,
int eventType)
{
@ -124,7 +124,7 @@ public Message getMessage()
* A timestamp indicating the exact date when the event occurred.
* @return a Date indicating when the event occurred.
*/
public long getTimestamp()
public Date getTimestamp()
{
return timestamp;
}

@ -32,7 +32,7 @@ public class MessageDeliveredEvent
/**
* A timestamp indicating the exact date when the event occurred.
*/
private final long timestamp;
private final Date timestamp;
/**
* The ID of the message being corrected, or null if this was a new message
@ -48,7 +48,7 @@ public class MessageDeliveredEvent
*/
public MessageDeliveredEvent(Message source, Contact to)
{
this(source, to, System.currentTimeMillis());
this(source, to, new Date());
}
/**
@ -62,7 +62,7 @@ public MessageDeliveredEvent(Message source, Contact to)
public MessageDeliveredEvent(Message source, Contact to,
String correctedMessageUID)
{
this(source, to, System.currentTimeMillis());
this(source, to, new Date());
this.correctedMessageUID = correctedMessageUID;
}
@ -75,7 +75,7 @@ public MessageDeliveredEvent(Message source, Contact to,
* @param timestamp a date indicating the exact moment when the event
* ocurred
*/
public MessageDeliveredEvent(Message source, Contact to, long timestamp)
public MessageDeliveredEvent(Message source, Contact to, Date timestamp)
{
super(source);
@ -109,7 +109,7 @@ public Message getSourceMessage()
* A timestamp indicating the exact date when the event occurred.
* @return a Date indicating when the event occurred.
*/
public long getTimestamp()
public Date getTimestamp()
{
return timestamp;
}

@ -49,7 +49,7 @@ public class MessageReceivedEvent
/**
* A timestamp indicating the exact date when the event occurred.
*/
private final long timestamp;
private final Date timestamp;
/**
* The type of message event that this instance represents.
@ -71,7 +71,7 @@ public class MessageReceivedEvent
* @param from the <tt>Contact</tt> that has sent this message.
* @param timestamp the exact date when the event ocurred.
*/
public MessageReceivedEvent(Message source, Contact from, long timestamp)
public MessageReceivedEvent(Message source, Contact from, Date timestamp)
{
this(source, from, timestamp, CONVERSATION_MESSAGE_RECEIVED);
}
@ -89,7 +89,7 @@ public MessageReceivedEvent(Message source, Contact from, long timestamp)
public MessageReceivedEvent(Message source, Contact from,
String correctedMessageUID)
{
this(source, from, System.currentTimeMillis(),
this(source, from, new Date(),
CONVERSATION_MESSAGE_RECEIVED);
this.correctedMessageUID = correctedMessageUID;
}
@ -105,7 +105,7 @@ public MessageReceivedEvent(Message source, Contact from,
* @param correctedMessageUID The ID of the message being corrected, or null if this is a new message
* and not a correction.
*/
public MessageReceivedEvent(Message source, Contact from, long timestamp,
public MessageReceivedEvent(Message source, Contact from, Date timestamp,
String correctedMessageUID)
{
this(source, from, timestamp,
@ -125,7 +125,7 @@ public MessageReceivedEvent(Message source, Contact from, long timestamp,
* (one of the XXX_MESSAGE_RECEIVED static fields).
*/
public MessageReceivedEvent(Message source, Contact from,
long timestamp, int eventType)
Date timestamp, int eventType)
{
super(source);
@ -161,7 +161,7 @@ public Message getSourceMessage()
*
* @return a Date indicating when the event occurred.
*/
public long getTimestamp()
public Date getTimestamp()
{
return timestamp;
}

@ -214,6 +214,22 @@ else if (day1 == day2)
}
}
/**
* Compares the two dates. The comparison is based only on the day, month
* and year values. Returns 0 if the two dates are equals, a value < 0 if
* the first date is before the second one and > 0 if the first date is
* after the second one.
* @param date1 the first date to compare
* @param date2 the second date to compare with
* @return Returns 0 if the two dates are equals, a value < 0 if
* the first date is before the second one and > 0 if the first date is
* after the second one
*/
public static int compareDatesOnly(Date date1, Date date2)
{
return compareDatesOnly(date1.getTime(), date2.getTime());
}
/**
* Formats the given date. The result format is the following:
* [Month] [Day], [Year]. For example: Dec 24, 2000.
@ -257,6 +273,24 @@ public static void formatDate(long date, StringBuffer dateStrBuf)
GuiUtils.formatTime(c1.get(Calendar.YEAR), dateStrBuf);
}
/**
* Formats the given date as: Month DD, YYYY and appends it to the given
* <tt>dateStrBuf</tt> string buffer.
* @param date the date to format
* @param dateStrBuf the <tt>StringBuffer</tt>, where to append the
* formatted date
*/
public static void formatDate(Date date, StringBuffer dateStrBuf)
{
c1.setTime(date);
dateStrBuf.append(GuiUtils.processMonth(c1.get(Calendar.MONTH)));
dateStrBuf.append(' ');
GuiUtils.formatTime(c1.get(Calendar.DAY_OF_MONTH), dateStrBuf);
dateStrBuf.append(", ");
GuiUtils.formatTime(c1.get(Calendar.YEAR), dateStrBuf);
}
/**
* Formats the time for the given date. The result format is the following:
* [Hour]:[Minute]:[Second]. For example: 12:25:30.

Loading…
Cancel
Save