Pubnub

作者: thebestofrocky | 来源:发表于2017-10-24 19:22 被阅读22次

https://www.pubnub.com/tutorials/android/getting-started/

实时推送平台,用于创建即时聊天

compile group: 'com.google.guava', name: 'guava', version: '19.0'
compile group: 'joda-time', name: 'joda-time', version: '2.9.4'

代码:

public static String getTimeStampUtc() {
        return DateTime.now(DateTimeZone.UTC).toString(ISODateTimeFormat.dateTime());
    }

public static String getTimeStampUtc(long instant) {
        return ISODateTimeFormat.dateTime().withZoneUTC().print(instant);
    }

toString

@Override
    public String toString() {
        return MoreObjects.toStringHelper(MultiPojo.class)
                .add("channel", channel)
                .add("sender", sender)
                .add("message", message)
                .add("timestamp", timestamp)
                .toString();
    }

判断是否同相同

public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (obj == this) {
            return true;
        }
        if (this.getClass() != obj.getClass()) {
            return false;
        }
        final MultiPojo other = (MultiPojo) obj;

        return Objects.equal(this.channel, other.channel)
                && Objects.equal(this.sender, other.sender)
                && Objects.equal(this.message, other.message)
                && Objects.equal(this.timestamp, other.timestamp);
    }

获取hashcode

public int hashCode() {
        return Objects.hashCode(channel, sender, message, timestamp);
    }

相关文章

  • Pubnub

    https://www.pubnub.com/tutorials/android/getting-started/...

网友评论

    本文标题:Pubnub

    本文链接:https://www.haomeiwen.com/subject/ywmxpxtx.html