helper.java
来自「是一款国外的网络游戏平台的源码*不是类似浩方那种虚拟局域网技术」· Java 代码 · 共 68 行
JAVA
68 行
/*
* Created on Jun 11, 2005
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package org.GTADS.helper;
import java.util.Date;
/**
* @author Administrator
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class Helper {
public static boolean server;
public static void setAsServer(boolean b){
server = b;
}
public static boolean isServer() {
return server;
}
public static String clipCarriageReturn(String s) {
if (s.length() >= 3) {
if (s.endsWith("\r\n")) {
s = s.substring(0,s.length() - 2);
return s;
}
}
return s;
}
public static String formatSingleTimeDigit(int numeral){
String correctedDigit = new String(numeral + "");
if (numeral >= 0 && numeral < 10)
correctedDigit = "0" + numeral;
return correctedDigit;
}
public static String getDate(boolean is24Hour) {
String zero = "0";
Date currentTime = new Date();
int currentHour = currentTime.getHours();
int currentMinute = currentTime.getMinutes();
int currentSecond = currentTime.getSeconds();
if (!is24Hour){
if (currentHour > 12) {
currentHour -= 12;
}
if (currentHour == 0){
currentHour = 12;
}
}
String hour = Helper.formatSingleTimeDigit(currentHour);
String minute = Helper.formatSingleTimeDigit(currentMinute);
String seconds = Helper.formatSingleTimeDigit(currentSecond);
return hour + ":" + minute + ":" + seconds;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?