本文整理匯總了Java中chatty.util.DateTime.duration方法的典型用法代碼示例。如果您正苦於以下問題:Java DateTime.duration方法的具體用法?Java DateTime.duration怎麽用?Java DateTime.duration使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類chatty.util.DateTime
的用法示例。
在下文中一共展示了DateTime.duration方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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);
}
}
}
}
示例2: 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+")");
}
}
}
示例3: 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);
}
}
示例4: 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+")");
}
}
}
示例5: 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;
}
示例6: 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, 1, 0) + " ago";
}
if (isAutoUpdating()) {
infoText += " (auto updating)";
if (ago > AUTO_UPDATE_DELAY
&& (lastError == -1 || errorAgo > AUTO_UPDATE_DELAY)) {
reload();
return;
}
}
if (lastError != -1) {
infoText += String.format(" [%s ago: %s]",
DateTime.duration(errorAgo, 2, 0),
errorMessage);
}
racesDialog.setStatusText(infoText);
}
}
示例7: formatDuration
import chatty.util.DateTime; //導入方法依賴的package包/類
private static String formatDuration(long time) {
return DateTime.duration(time, H, 2, S);
}