📄 helper.java
字号:
/*
* 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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -