List of usage examples for java.util Formatter format
public Formatter format(String format, Object... args)
From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccDb2LUW.CFAccDb2LUWSchema.java
public static String getDateString(Calendar val) { if (val == null) { return ("null"); } else {// w ww . j a v a2 s . c o m StringBuffer buff = new StringBuffer(); Formatter fmt = new Formatter(buff); Calendar db = CFLibDbUtil.getDbServerCalendar(val); fmt.format("%1$04d", db.get(Calendar.YEAR)); buff.append("-"); fmt.format("%1$02d", db.get(Calendar.MONTH) + 1); buff.append("-"); fmt.format("%1$02d", db.get(Calendar.DAY_OF_MONTH)); fmt.close(); return (buff.toString()); } }
From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccDb2LUW.CFAccDb2LUWSchema.java
public static String getTimeString(Calendar val) { if (val == null) { return ("null"); } else {//from w w w.j a v a2 s . c o m StringBuffer buff = new StringBuffer(); Formatter fmt = new Formatter(buff); Calendar db = CFLibDbUtil.getDbServerCalendar(val); fmt.format("%1$02d", db.get(Calendar.HOUR_OF_DAY)); buff.append("."); fmt.format("%1$02d", db.get(Calendar.MINUTE)); buff.append("."); fmt.format("%1$02d", db.get(Calendar.SECOND)); fmt.close(); return (buff.toString()); } }
From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccDb2LUW.CFAccDb2LUWSchema.java
public static String getQuotedDateString(Calendar val) { if (val == null) { return ("null"); } else {/*from w ww . j av a 2 s.c o m*/ StringBuffer buff = new StringBuffer("'"); Formatter fmt = new Formatter(buff); Calendar db = CFLibDbUtil.getDbServerCalendar(val); fmt.format("%1$04d", db.get(Calendar.YEAR)); buff.append("-"); fmt.format("%1$02d", db.get(Calendar.MONTH) + 1); buff.append("-"); fmt.format("%1$02d", db.get(Calendar.DAY_OF_MONTH)); buff.append("'"); fmt.close(); return (buff.toString()); } }
From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccDb2LUW.CFAccDb2LUWSchema.java
public static String getQuotedTimeString(Calendar val) { if (val == null) { return ("null"); } else {//from ww w . ja v a2 s . c o m StringBuffer buff = new StringBuffer("'"); Formatter fmt = new Formatter(buff); Calendar db = CFLibDbUtil.getDbServerCalendar(val); fmt.format("%1$02d", db.get(Calendar.HOUR_OF_DAY)); buff.append("."); fmt.format("%1$02d", db.get(Calendar.MINUTE)); buff.append("."); fmt.format("%1$02d", db.get(Calendar.SECOND)); buff.append("'"); fmt.close(); return (buff.toString()); } }
From source file:com.itemanalysis.jmetrik.stats.itemanalysis.ItemAnalysis.java
public String getResults() throws IllegalArgumentException { StringBuilder headerBuffer = new StringBuilder(); Formatter f = new Formatter(headerBuffer); int outputMidpoint = 37; String s1 = String.format("%1$tB %1$te, %1$tY %tT", Calendar.getInstance()); int len = outputMidpoint + Double.valueOf(Math.floor(Double.valueOf(s1.length()).doubleValue() / 2.0)).intValue(); String dString = ""; dString = command.getDataString();//ww w. j a va 2s. c o m int len2 = outputMidpoint + Double.valueOf(Math.floor(Double.valueOf(dString.length()).doubleValue() / 2.0)).intValue(); f.format("%43s", "ITEM ANALYSIS"); f.format("%n"); f.format("%" + len2 + "s", dString); f.format("%n"); f.format("%" + len + "s", s1); f.format("%n"); f.format("%-70s", "======================================================================"); f.format("%n"); f.format("%n"); StringBuilder buffer = new StringBuilder(); buffer.append(f.toString()); int counter = 0; int nItems = item.size(); ClassicalItem temp; if (showItemStats) { for (Integer i : item.keySet()) { temp = item.get(i); if (counter == 0 || command.getSelectAllOption("options").isArgumentSelected("header")) { buffer.append(temp.printHeader()); } buffer.append(temp.toString()); if (command.getSelectAllOption("options").isArgumentSelected("all") || command.getSelectAllOption("options").isArgumentSelected("header")) { if (counter < (nItems - 1)) buffer.append("\n"); } counter++; } } buffer.append("======================================================================"); buffer.append("\n\n"); buffer.append(testSummary.print()); return buffer.toString(); }
From source file:com.itemanalysis.psychometrics.irt.model.Irm4PL.java
/** * A string representaiton of the item parameters. Mainly used for printing and debugging. * * @return a string of item parameters./*from ww w. ja v a2 s . co m*/ */ @Override public String toString() { StringBuilder sb = new StringBuilder(); Formatter f = new Formatter(sb); String name = ""; if (getName() != null) { name = getName().toString(); } f.format("%-18s", name); f.format("%2s", ""); f.format("%-3s", "L4"); f.format("%4s", ""); f.format("% 4.2f", getDiscrimination()); f.format("%1s", ""); f.format("(%4.2f)", getDiscriminationStdError()); f.format("%4s", ""); f.format("% 4.2f", getDifficulty()); f.format("%1s", ""); f.format("(%4.2f)", getDifficultyStdError()); f.format("%4s", ""); f.format("% 4.2f", getGuessing()); f.format("%1s", ""); f.format("(%4.2f)", getGuessingStdError()); f.format("%4s", ""); f.format("% 4.2f", getSlipping()); f.format("%1s", ""); f.format("(%4.2f)", getSlippingStdError()); f.format("%4s", ""); return f.toString(); // // // StringBuilder sb = new StringBuilder(); // Formatter f = new Formatter(sb); // // f.format("%10s", getName().toString());f.format("%2s", ": "); // f.format("%1s", "["); // f.format("% .6f", getDiscrimination()); f.format("%2s", ", "); // f.format("% .6f", getDifficulty()); f.format("%2s", ", "); // f.format("% .6f", getGuessing()); f.format("%2s", ", "); // f.format("% .6f", getSlipping());f.format("%1s", "]"); // f.format("%n"); // f.format("%10s", "");f.format("%2s", ""); // f.format("%1s", "("); // f.format("% .6f", getDiscriminationStdError()); f.format("%2s", ", "); // f.format("% .6f", getDifficultyStdError()); f.format("%2s", ", "); // f.format("% .6f", getGuessingStdError()); f.format("%2s", ", "); // f.format("% .6f", getSlippingStdError());f.format("%1s", ")"); // return f.toString(); }
From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccDb2LUW.CFAccDb2LUWSchema.java
public static String getTimestampString(Calendar val) { if (val == null) { return ("null"); } else {// w w w . j a v a 2 s .c o m StringBuffer buff = new StringBuffer(); Formatter fmt = new Formatter(buff); Calendar db = CFLibDbUtil.getDbServerCalendar(val); fmt.format("%1$04d", db.get(Calendar.YEAR)); buff.append("-"); fmt.format("%1$02d", db.get(Calendar.MONTH) + 1); buff.append("-"); fmt.format("%1$02d", db.get(Calendar.DAY_OF_MONTH)); buff.append("-"); fmt.format("%1$02d", db.get(Calendar.HOUR_OF_DAY)); buff.append("."); fmt.format("%1$02d", db.get(Calendar.MINUTE)); buff.append("."); fmt.format("%1$02d", db.get(Calendar.SECOND)); fmt.close(); return (buff.toString()); } }
From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccDb2LUW.CFAccDb2LUWSchema.java
public static String getQuotedTimestampString(Calendar val) { if (val == null) { return ("null"); } else {/* w w w . j a v a 2 s . c o m*/ StringBuffer buff = new StringBuffer("'"); Formatter fmt = new Formatter(buff); Calendar db = CFLibDbUtil.getDbServerCalendar(val); fmt.format("%1$04d", db.get(Calendar.YEAR)); buff.append("-"); fmt.format("%1$02d", db.get(Calendar.MONTH) + 1); buff.append("-"); fmt.format("%1$02d", db.get(Calendar.DAY_OF_MONTH)); buff.append("-"); fmt.format("%1$02d", db.get(Calendar.HOUR_OF_DAY)); buff.append("."); fmt.format("%1$02d", db.get(Calendar.MINUTE)); buff.append("."); fmt.format("%1$02d", db.get(Calendar.SECOND)); buff.append("'"); fmt.close(); return (buff.toString()); } }
From source file:integration.DeleteServiceFilesTest.java
/** * Forms a path depending on the type of file to be deleted * and its id./*from w w w . j a v a2 s .c om*/ * * @param dataDir The path to the directory * @param klass The type of object to handle. * @param id The identifier of the object. */ private String getPath(String klass, Long id) throws Exception { String suffix = ""; String prefix = ""; Long remaining = id; Long dirno = 0L; if (id == null) { throw new NullPointerException("Expecting a not-null id."); } if (klass.equals(REF_ORIGINAL_FILE)) { prefix = FilenameUtils.concat(dataDir, "Files"); } else if (klass.equals(REF_PIXELS)) { prefix = FilenameUtils.concat(dataDir, "Pixels"); } else if (klass.equals(REF_THUMBNAIL)) { prefix = FilenameUtils.concat(dataDir, "Thumbnails"); } else { throw new Exception("Unknown class: " + klass); } while (remaining > 999) { remaining /= 1000; if (remaining > 0) { Formatter formatter = new Formatter(); dirno = remaining % 1000; suffix = formatter.format("Dir-%03d", dirno).out().toString() + File.separator + suffix; } } String path = FilenameUtils.concat(prefix, suffix + id); return path; }
From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccMSSql.CFAccMSSqlSchema.java
public static String getDateString(Calendar val) { if (val == null) { return ("null"); } else {/* www .jav a 2 s .co m*/ Calendar db = CFLibDbUtil.getDbServerCalendar(val); StringBuffer buff = new StringBuffer(); Formatter fmt = new Formatter(buff); fmt.format("%1$04d", db.get(Calendar.YEAR)); fmt.format("%1$02d", db.get(Calendar.MONTH) + 1); fmt.format("%1$02d", db.get(Calendar.DAY_OF_MONTH)); fmt.close(); return (buff.toString()); } }