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.CFAccMSSql.CFAccMSSqlSchema.java
public static String getTZDateString(Calendar val) { if (val == null) { return ("null"); } else {//w w w . j a v a 2 s .c om Calendar db = CFLibDbUtil.getDbServerCalendar(val); StringBuffer buff = new StringBuffer(); Formatter fmt = new Formatter(buff); 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.CFAccMSSql.CFAccMSSqlSchema.java
public static String getTZTimeString(Calendar val) { if (val == null) { return ("null"); } else {/*from www . j a va 2s . co m*/ Calendar db = CFLibDbUtil.getDbServerCalendar(val); StringBuffer buff = new StringBuffer(); Formatter fmt = new Formatter(buff); 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.CFAccMSSql.CFAccMSSqlSchema.java
public static String getTZTimestampString(Calendar val) { if (val == null) { return ("null"); } else {/* w ww. java2 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)); 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.CFAccMSSql.CFAccMSSqlSchema.java
public static String getQuotedTZDateString(Calendar val) { if (val == null) { return ("null"); } else {//from ww w . j a va 2 s . c o m Calendar db = CFLibDbUtil.getDbServerCalendar(val); StringBuffer buff = new StringBuffer("'"); Formatter fmt = new Formatter(buff); 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:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccMSSql.CFAccMSSqlSchema.java
public static String getQuotedTZTimeString(Calendar val) { if (val == null) { return ("null"); } else {/* w w w .j a va2 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)); 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:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccMSSql.CFAccMSSqlSchema.java
public static String getQuotedTZTimestampString(Calendar val) { if (val == null) { return ("null"); } else {/*from w w w . j a va 2 s . c o m*/ Calendar db = CFLibDbUtil.getDbServerCalendar(val); StringBuffer buff = new StringBuffer("'"); Formatter fmt = new Formatter(buff); 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:com.jaspersoft.jasperserver.util.test.BaseServiceSetupTestNG.java
public String msg(String text, Object... info) { StringBuilder sb = new StringBuilder(); Formatter formatter = new Formatter(sb, LocaleContextHolder.getLocale()); formatter.format(text, info); return sb.toString(); }
From source file:org.kalypso.kalypsomodel1d2d.sim.ResultManager.java
private void processSWANTabFile(final FileObject swanResOutTabFile, final FileObject swanResShiftFile) { final GM_Position lShiftPosition = SWANDataConverterHelper.readCoordinateShiftValues(swanResShiftFile); if (lShiftPosition == null) { return;// w w w . j a v a2s . c om } try { if (swanResOutTabFile.isContentOpen()) { swanResOutTabFile.close(); } final FileObject swanResOutTabFileBackUp = swanResOutTabFile.getParent() .resolveFile(swanResOutTabFile.getName().getBaseName() + ".bck"); //$NON-NLS-1$ swanResOutTabFile.moveTo(swanResOutTabFileBackUp); // int lIntLinesCounter = 0; final OutputStream lOutStream = swanResOutTabFile.getContent().getOutputStream(); final DataInputStream lInDataStream = new DataInputStream( swanResOutTabFileBackUp.getContent().getInputStream()); BufferedReader streamReader = new BufferedReader(new InputStreamReader(lInDataStream)); final Formatter lFormatter = new Formatter(lOutStream, Charset.defaultCharset().name(), Locale.US); while (lInDataStream.available() != 0) { final String lStrTmpLine = streamReader.readLine().trim(); // ++lIntLinesCounter; if (lStrTmpLine.startsWith("%")) { //$NON-NLS-1$ lFormatter.format("%s\n", lStrTmpLine); //$NON-NLS-1$ continue; } final StringTokenizer lStrTokenizer = new StringTokenizer(lStrTmpLine, " "); //$NON-NLS-1$ int lIntTokenCounter = 0; String lStrNewLine = ""; //$NON-NLS-1$ while (lStrTokenizer.hasMoreTokens()) { final String lStrToken = lStrTokenizer.nextToken(); if (lIntTokenCounter == 1) { lStrNewLine += String.format(Locale.US, "%.5f\t", //$NON-NLS-1$ NumberUtils.parseQuietDouble(lStrToken) + lShiftPosition.getX()); } else if (lIntTokenCounter == 2) { lStrNewLine += String.format(Locale.US, "%.5f\t", //$NON-NLS-1$ NumberUtils.parseQuietDouble(lStrToken) + lShiftPosition.getY()); } else { lStrNewLine += lStrToken + "\t"; //$NON-NLS-1$ } lIntTokenCounter++; } lFormatter.format("%s\n", lStrNewLine); //$NON-NLS-1$ } lFormatter.close(); lInDataStream.close(); lOutStream.close(); } catch (final Exception e) { return; } return; }
From source file:com.itemanalysis.psychometrics.irt.model.IrmGPCM.java
/** * Displays the item parameter values and standard errors. * * @return String representation of item parameter values and standard errors. *///from w ww . j a v a2 s. co m public String toString() { StringBuilder sb = new StringBuilder(); Formatter f = new Formatter(sb); String name = getName().toString(); if (getName() != null) { name = getName().toString().substring(0, Math.min(18, name.length())); } else { name = ""; } f.format("%-18s", name); f.format("%2s", ""); f.format("%-3s", "PC1"); f.format("%4s", ""); f.format("% 4.2f", getDiscrimination()); f.format("%1s", ""); f.format("(%4.2f)", getDiscriminationStdError()); f.format("%4s", ""); double[] step = getStepParameters(); double[] stepSe = getStepStdError(); for (int k = 1; k < ncat; k++) { if (k > 1) f.format("%43s", ""); f.format("% 2.2f", step[k]); f.format("%1s", ""); f.format("(%2.2f)", stepSe[k]); if (k < ncatM1) f.format("%n"); } 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", ", "); // for(int k=1;k<ncat;k++){ // f.format("% .6f", step[k]);//Do not print first step parameter because fixed to zero. // if(k<ncatM1) f.format("%2s", ", "); // } // f.format("%1s", "]"); // f.format("%n"); // f.format("%10s", "");f.format("%2s", ""); // f.format("%1s", "("); // f.format("% .6f", getDiscriminationStdError()); f.format("%2s", ", "); // for(int k=1;k<ncat;k++){ // f.format("% .6f", stepStdError[k]);//Do not print first step parameter because fixed to zero. // if(k<ncatM1) f.format("%2s", ", "); // } // f.format("%1s", ")"); // // return f.toString(); }
From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccMSSql.CFAccMSSqlSchema.java
public static String getTimeString(Calendar val) { if (val == null) { return ("null"); } else {/*from w w w.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$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()); } }