当前位置: 首页>>代码示例>>Java>>正文


Java DateTime类代码示例

本文整理汇总了Java中chatty.util.DateTime的典型用法代码示例。如果您正苦于以下问题:Java DateTime类的具体用法?Java DateTime怎么用?Java DateTime使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DateTime类属于chatty.util包,在下文中一共展示了DateTime类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: timeout

import chatty.util.DateTime; //导入依赖的package包/类
/**
 * Sends a timeout command to the server.
 * 
 * @param channel
 * @param name
 * @param time 
 */
public void timeout(String channel, String msgId, String name, long time, String reason) {
    if (onChannel(channel, true)) {
        MsgTags tags = createTags(msgId);
        if (time <= 0) {
            sendMessage(channel,".timeout "+name, "Trying to timeout "+name+"..", tags);
        }
        else {
            String formatted = DateTime.duration(time*1000, 0, 2, 0);
            String onlySeconds = time+"s";
            String timeString = formatted.equals(onlySeconds)
                    ? onlySeconds : onlySeconds+"/"+formatted;
            if (reason == null || reason.isEmpty()) {
                sendMessage(channel,".timeout "+name+" "+time,
                    "Trying to timeout "+name+" ("+timeString+")", tags);
            } else {
                sendMessage(channel,".timeout "+name+" "+time+" "+reason,
                    "Trying to timeout "+name+" ("+timeString+", "+reason+")", tags);
            }
        }
        
    }
}
 
开发者ID:chatty,项目名称:chatty,代码行数:30,代码来源:TwitchCommands.java

示例2: getStatus

import chatty.util.DateTime; //导入依赖的package包/类
/**
 * Get Websocket status in text form, with some basic formatting.
 * 
 * @return 
 */
public synchronized String getStatus() {
    if (!connecting) {
        return "Not connected";
    }
    if (s != null && s.isOpen()) {
        return String.format("Connected for %s\n"
                + "\tServer: %s\n"
                + "\tCommands sent: %d (last %s ago)\n"
                + "\tMessages received: %d (last %s ago)\n"
                + "\tLatency: %dms (%s)",
                
                DateTime.ago(timeConnected),
                s.getRequestURI(),
                sentCount,
                DateTime.ago(timeLastMessageSent),
                receivedCount,
                DateTime.ago(timeLastMessageReceived),
                lastMeasuredLatency,
                timeLatencyMeasured == 0 ? "not yet measured" : "measured "+DateTime.ago(timeLatencyMeasured)+" ago");
    }
    return "Connecting..";
}
 
开发者ID:chatty,项目名称:chatty,代码行数:28,代码来源:WebsocketClient.java

示例3: addError

import chatty.util.DateTime; //导入依赖的package包/类
private void addError(LogRecord error, LinkedList<LogRecord> previous) {
    errorCount++;
    String errorText = makeErrorText(error, previous);
    errors.add(errorText);
    if (errorCount == 1) {
        setTitle("Error");
        debugMessage.setText(String.format("Error Report // %s / %s / %s / %s\n\n",
                DateTime.fullDateTime(),
                Chatty.chattyVersion(),
                Helper.systemInfo(),
                LogUtil.getMemoryUsage()));
    } else {
        setTitle(errorCount+" Errors");
    }
    debugMessage.append(errorText);
}
 
开发者ID:chatty,项目名称:chatty,代码行数:17,代码来源:ErrorMessage.java

示例4: makeErrorText

import chatty.util.DateTime; //导入依赖的package包/类
private String makeErrorText(LogRecord error, LinkedList<LogRecord> previous) {
    StringBuilder b = new StringBuilder();
    for (LogRecord r : previous) {
        // Should never be null, but since this may contain null and it
        // apparently happened before..
        if (r != null) {
            b.append(DateTime.format(r.getMillis()));
            b.append(" ");
            b.append(r.getMessage());
            b.append("\n");
        }
    }
    b.append(DateTime.format(error.getMillis()));
    b.append(" Unhandled Exception:\n");
    b.append(error.getMessage());
    b.append("\n\n");
    return b.toString();
}
 
开发者ID:chatty,项目名称:chatty,代码行数:19,代码来源:ErrorMessage.java

示例5: update

import chatty.util.DateTime; //导入依赖的package包/类
public void update() {
    if (!loading && infoLastLoaded > 0) {
        long timePassed = System.currentTimeMillis() - infoLastLoaded;
        if (statusEdited) {
            updated.setText(Language.getString("admin.infoLoaded.edited", DateTime.duration(timePassed, 1, 0)));
        } else {
            updated.setText(Language.getString("admin.infoLoaded", DateTime.duration(timePassed, 1, 0)));
        }
    }
    if (loading && lastPutResult > 0) {
        long ago = System.currentTimeMillis() - lastPutResult;
        if (ago > PUT_RESULT_DELAY) {
            setLoading(false);
        }
    }
}
 
开发者ID:chatty,项目名称:chatty,代码行数:17,代码来源:StatusPanel.java

示例6: add

import chatty.util.DateTime; //导入依赖的package包/类
public void add(ModeratorActionData data) {
    if (data.stream == null) {
        return;
    }
    String channel = data.stream;
    
    String line = String.format("[%s] <%s> /%s %s",
            DateTime.currentTime(),
            data.created_by,
            data.moderation_action,
            StringUtil.join(data.args," "));
    
    if (channel.equals(currentChannel)) {
        printLine(log, line);
    }
    
    if (!cache.containsKey(channel)) {
        cache.put(channel, new ArrayList<String>());
    }
    cache.get(channel).add(line);
}
 
开发者ID:chatty,项目名称:chatty,代码行数:22,代码来源:ModerationLog.java

示例7: timeout

import chatty.util.DateTime; //导入依赖的package包/类
/**
 * Sends a timeout command to the server.
 * 
 * @param channel
 * @param name
 * @param time 
 */
public void timeout(String channel, String name, long time) {
    if (onChannel(channel, true)) {
        if (time <= 0) {
            sendMessage(channel,".timeout "+name, "Trying to timeout "+name+"..");
        }
        else {
            String formatted = DateTime.duration(time, true, false);
            String onlySeconds = time+"s";
            String timeString = formatted.equals(onlySeconds)
                    ? onlySeconds : onlySeconds+"/"+formatted;
            sendMessage(channel,".timeout "+name+" "+time,
                    "Trying to timeout "+name+" ("+timeString+")");
        }
        
    }
}
 
开发者ID:partouf,项目名称:Chatty-Twitch-Client,代码行数:24,代码来源:TwitchCommands.java

示例8: commandGetCase

import chatty.util.DateTime; //导入依赖的package包/类
public synchronized String commandGetCase(String parameter) {
    if (parameter == null) {
        return "Usage: /getCase <name>";
    }
    String name = parameter.split(" ")[0];
    if (!Helper.validateStream(name)) {
        return "Invalid name.";
    } else {
        CapitalizedName cached = names.get(StringUtil.toLowerCase(name));
        if (cached == null) {
            return "No capitalization set for "+name;
        }
        String timeInfo = cached.time == -1 ? "set at unknown time"
                : "set "+DateTime.ago4(cached.time)+" ago, "+DateTime.formatFullDatetime(cached.time);
        return "Capitalization for " + name + " is "+cached.capitalizedName+" ("+(cached.fixed ? "manually " : "")+timeInfo+")";
    }
}
 
开发者ID:partouf,项目名称:Chatty-Twitch-Client,代码行数:18,代码来源:CapitalizedNames.java

示例9: update

import chatty.util.DateTime; //导入依赖的package包/类
private void update() {
    if (loading) {
        racesDialog.setStatusText("Loading..");
    } else {
        String infoText = "";

        long ago = System.currentTimeMillis() - lastReceived;
        long errorAgo = System.currentTimeMillis() - lastError;
        if (lastReceived > 0) {
            infoText += "Last updated: "
                    + DateTime.duration(ago, true) + " ago";
        }
        if (isAutoUpdating()) {
            infoText += " (auto updating)";
            if (ago > AUTO_UPDATE_DELAY
                    && (lastError == -1 || errorAgo > AUTO_UPDATE_DELAY)) {
                reload();
                return;
            }
        }
        if (lastError != -1) {
            infoText += " [" + DateTime.duration(errorAgo, true) + " ago: " + errorMessage + "]";
        }
        racesDialog.setStatusText(infoText);
    }
}
 
开发者ID:partouf,项目名称:Chatty-Twitch-Client,代码行数:27,代码来源:SRL.java

示例10: setUser

import chatty.util.DateTime; //导入依赖的package包/类
public void setUser(User user, String localUsername) {
    currentUser = user;
    currentLocalUsername = localUsername;
    
    //infoPane.setComponentPopupMenu(new UserContextMenu(user, contextMenuListener));
    
    String categoriesString = "";
    Set<String> categories = user.getCategories();
    if (categories != null && !categories.isEmpty()) {
        categoriesString = categories.toString();
    }
    String displayNickInfo = user.hasDisplayNickSet() ? "" : "*";
    this.setTitle("User: "+user.toString()+displayNickInfo+" / "+user.getChannel()+" "+categoriesString);
    lines.setText(null);
    lines.setText(makeLines());
    firstSeen.setText(" First seen: "+DateTime.format(user.getCreatedAt()));
    numberOfLines.setText(" Number of messages: "+user.getNumberOfMessages());
    updateColor();
    updateModButtons();
    finishDialog();
}
 
开发者ID:partouf,项目名称:Chatty-Twitch-Client,代码行数:22,代码来源:UserInfo.java

示例11: makeLines

import chatty.util.DateTime; //导入依赖的package包/类
private String makeLines() {
    StringBuilder b = new StringBuilder();
    if (currentUser.maxNumberOfLinesReached()) {
        b.append("<only last ");
        b.append(currentUser.getMaxNumberOfLines());
        b.append(" lines are saved>\n");
    }
    List<Message> messages = currentUser.getMessages();
    for (Message m : messages) {
        if (m.getType() == Message.MESSAGE) {
            b.append(DateTime.format(m.getTime(), TIMESTAMP_MESSAGE));
            b.append(((TextMessage)m).getText());
            b.append("\n");
        }
        else if (m.getType() == Message.BAN) {
            b.append(DateTime.format(m.getTime(), TIMESTAMP_SPECIAL));
            b.append("Banned from talking");
            b.append("\n");
        }
    }
    return b.toString();
}
 
开发者ID:partouf,项目名称:Chatty-Twitch-Client,代码行数:23,代码来源:UserInfo.java

示例12: update

import chatty.util.DateTime; //导入依赖的package包/类
/**
 * Update the last loaded label and the stats.
 */
private void update() {
    if (currentInfo != null) {
        if (currentInfo.requestError) {
            if (lastUpdated != -1) {
                loadInfo.setText(currentInfo.requestErrorDescription
                        + " (" + DateTime.ago4compact(currentInfo.time)
                        + " ago, updated " + DateTime.ago4compact(lastUpdated) + " ago)");
            } else {
                loadInfo.setText(currentInfo.requestErrorDescription
                        + " (" + DateTime.ago4compact(currentInfo.time) + " ago)");
            }
        } else {
            loadInfo.setText("Last updated "+DateTime.ago4(lastUpdated)+" ago");
        }
    }
    if (loading) {
        loadInfo.setText("Loading..");
    }
    updateStats();
}
 
开发者ID:partouf,项目名称:Chatty-Twitch-Client,代码行数:24,代码来源:FollowersDialog.java

示例13: timeout

import chatty.util.DateTime; //导入依赖的package包/类
/**
 * Sends a timeout command to the server.
 * 
 * @param channel
 * @param name
 * @param time 
 */
public void timeout(String channel, String name, int time) {
    if (onChannel(channel, true)) {
        if (time <= 0) {
            sendMessage(channel,".timeout "+name, "Trying to timeout "+name+"..");
        }
        else {
            String formatted = DateTime.duration(time, true, false);
            String onlySeconds = time+"s";
            String timeString = formatted.equals(onlySeconds)
                    ? onlySeconds : onlySeconds+"/"+formatted;
            sendMessage(channel,".timeout "+name+" "+time,
                    "Trying to timeout "+name+" ("+timeString+")");
        }
        
    }
}
 
开发者ID:pokemane,项目名称:TwitchChatClient,代码行数:24,代码来源:TwitchCommands.java

示例14: setUser

import chatty.util.DateTime; //导入依赖的package包/类
public void setUser(User user, String localUsername) {
    currentUser = user;
    currentLocalUsername = localUsername;
    
    //infoPane.setComponentPopupMenu(new UserContextMenu(user, contextMenuListener));
    
    String categoriesString = "";
    Set<String> categories = user.getCategories();
    if (categories != null && !categories.isEmpty()) {
        categoriesString = categories.toString();
    }
    this.setTitle("User: "+user.toString()+" / "+user.getChannel()+" "+categoriesString);
    lines.setText(null);
    lines.setText(makeLines());
    firstSeen.setText(" First seen: "+DateTime.format(user.getCreatedAt()));
    numberOfLines.setText(" Number of messages: "+user.getNumberOfMessages());
    updateColor();
    updateModButtons();
    finishDialog();
}
 
开发者ID:pokemane,项目名称:TwitchChatClient,代码行数:21,代码来源:UserInfo.java

示例15: updateInfo

import chatty.util.DateTime; //导入依赖的package包/类
/**
 * Update the info text once a state has been updated.
 */
private void updateInfo() {
    String result = "";
    String sep = "|";
    if (slowMode == SLOWMODE_ON_INVALID || slowMode > 86400) {
        result += "Slow: >day";
    } else if (slowMode > 999) {
        result += "Slow: "+DateTime.duration(slowMode*1000, 1, 0);
    } else if (slowMode > 0) {
        result += "Slow: "+slowMode;
    }
    if (subMode) {
        result = StringUtil.append(result, sep, "Sub");
    }
    if (followersOnly == SLOWMODE_ON_INVALID) {
        result = StringUtil.append(result, sep, "Followers: ?");
    } else if (followersOnly > 0) {
        result = StringUtil.append(result, sep, "Followers: "+DateTime.duration((long)followersOnly*60*1000, 1, DateTime.S, DateTime.Formatting.COMPACT));
    } else if (followersOnly == 0) {
        result = StringUtil.append(result, sep, "Followers");
    }
    if (r9kMode) {
        result = StringUtil.append(result, sep, "r9k");
    }
    if (emoteOnly) {
        result = StringUtil.append(result, sep, "EmoteOnly");
    }
    if (hosting != null && !hosting.isEmpty()) {
        result = StringUtil.append(result, sep, "Hosting: "+hosting);
    }
    if (lang != null && !lang.isEmpty()) {
        result = StringUtil.append(result, sep, lang);
    }
    if (!result.isEmpty()) {
        result = "["+result+"]";
    }
    info = result;
}
 
开发者ID:chatty,项目名称:chatty,代码行数:41,代码来源:ChannelState.java


注:本文中的chatty.util.DateTime类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。