你好,如下設(shè)置可以實(shí)現(xiàn):
成都創(chuàng)新互聯(lián)-專業(yè)網(wǎng)站定制、快速模板網(wǎng)站建設(shè)、高性價(jià)比青云譜網(wǎng)站開發(fā)、企業(yè)建站全套包干低至880元,成熟完善的模板庫,直接使用。一站式青云譜網(wǎng)站制作公司更省心,省錢,快速模板網(wǎng)站建設(shè)找我們,業(yè)務(wù)覆蓋青云譜地區(qū)。費(fèi)用合理售后完善,十多年實(shí)體公司更值得信賴。
打開eclipse選擇Window -Preferences
再選擇 Web = HTML Files = Editor
在 Inline Elements列表里添加所有的標(biāo)簽進(jìn)去
然后按 CTRL+SHIFT+F就可以格式化了。
時(shí)間格式化輸出主要有兩種方式,代碼如下:
//使用Calendar
Calendar now = Calendar.getInstance();
System.out.println("年:" + now.get(Calendar.YEAR));
System.out.println("月:" + (now.get(Calendar.MONTH) + 1));
System.out.println("日:" + now.get(Calendar.DAY_OF_MONTH));
System.out.println("時(shí):" + now.get(Calendar.HOUR_OF_DAY));
System.out.println("分:" + now.get(Calendar.MINUTE));
ystem.out.println("秒:" + now.get(Calendar.SECOND));
//使用Date
Date d = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
System.out.println("當(dāng)前時(shí)間:" + sdf.format(d));
擴(kuò)展資料
JAVA中獲取當(dāng)前系統(tǒng)時(shí)間。
import java.util.Date;
import java.text.SimpleDateFormat;
public class NowString {
public static void main(String[] args) {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//設(shè)置日期格式
System.out.println(df.format(new Date()));// new Date()為獲取當(dāng)前系統(tǒng)時(shí)間
}
}
參考資料來源:百度百科:Java
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
public class FormateBankAccountId {
ListString standardBankAccountIdFormat ;
public FormateBankAccountId(String propertiesFileName) throws FileNotFoundException, IOException
{
// 加載資源文件
Properties properties = new Properties();
properties.load(new FileReader(propertiesFileName));
this.standardBankAccountIdFormat = new ArrayListString();
int keyNumber = 1;
String value = null;
// 讀取鍵值對,鍵的格式是: formate_1 ,..., formate_10,...,formate_100 等
while( ( value = properties.getProperty("formate_" + keyNumber++) ) != null)
{
value = value.trim();
this.standardBankAccountIdFormat.add(value);
}
}
public ListString formate(String orginalBankAccountId)
{
ListString proceededlBankAccountIds = new :
樓主你好!給你寫了個(gè)測試類希望能幫助你。這兩個(gè)個(gè)方法只需要傳入你要格式話的數(shù)據(jù),就可以返回你想要的結(jié)果了。 package com.line;public class T9 {
/**
* b格式化一般數(shù)據(jù)為財(cái)務(wù)格式,eg:123,456,789.00/b
*
* @param source
* String
* @return String
*/
public static String getCaiWuData(String source) {
StringBuffer str = new StringBuffer("");
if (source != null !source.equals("") source.length() 0
!source.equals("null")) {
if (source.lastIndexOf(",") 0) {
source =formatStr(source);
}
int dotIndex = 0;
if (source.indexOf(".") 0) {
source += ".00";
}
dotIndex = source.indexOf(".");
int index = 0;
String opt = "";
opt = source.substring(0, 1);
if (opt.equals("-")) {
source = source.substring(1);
str.append("-");
dotIndex = source.indexOf(".");
}
if (dotIndex 3) {
index += 1;
str.append(source.substring(0, dotIndex));
}
if (dotIndex % 3 == 0) {
index += dotIndex / 3;
} else {
index += (dotIndex - dotIndex % 3) / 3;
}
if (index 0 dotIndex = 3) {
for (int i = index; i 0; i--) {
if (i == index) {
str.append(source.substring(0, dotIndex - i * 3));
}
if (dotIndex - i * 3 0) {
str.append(",");
}
if (i = 1) {
str.append(source.substring(dotIndex - i * 3, dotIndex
- (i - 1) * 3));
}
}
}
str.append(source.substring(dotIndex));
}
if (source.length() - source.lastIndexOf(".") 3) {
str.append("0");
}
int dot_index = str.toString().indexOf(".") + 2;
int str_len = str.toString().length();
char[] strArr = str.toString().toCharArray();
StringBuffer rev = new StringBuffer();
for (int i = str_len - 1; i 0; i--) {// 除去尾數(shù)0,小數(shù)點(diǎn)后保留2位
if (i dot_index
Integer.parseInt(new Character(strArr[i]).toString()) 0) {
rev.append(str.toString().substring(0, i + 1));
break;
} else if (i == dot_index (int) strArr[i] = 0) {
rev.append(str.toString().substring(0, dot_index + 1));
break;
}
}
return rev.toString();
}
/**
* b格式化財(cái)務(wù)數(shù)據(jù)為一般字符串,eg:123456789.00/b
*
* @param source
* String
* @return String
*/
public static String formatStr(String source) {
StringBuffer str = new StringBuffer("");
if (source != null !source.equals("") source.length() 0
!source.equals("null")) {
String temp = source.substring(0, 1);
if (temp.equals("-")) {
source = source.substring(1);
str.append("-");
}
String[] myarr = source.split(",");
int lastIndex = source.lastIndexOf(",");
if (lastIndex 0) {
for (int i = 0; i myarr.length; i++) {
str.append(myarr[i]);
}
}
if (source.lastIndexOf(",") 0) {
str.append(source);
}
if (source.lastIndexOf(".") 0) {
str.append(".00");
}
if (source.length() - source.lastIndexOf(".") 3
!"0".equals(source)) {
str.append("0");
}
} else {
return (str.append("0.00").toString());
}
return str.toString();
}
/**
* @param args
*/
public static void main(String[] args) {
T9 t=new T9();
System.out.println(t.getCaiWuData("1231313"));
System.out.println(t.formatStr("1,231,313.00"));
}}