List of usage examples for java.util Formatter format
public Formatter format(String format, Object... args)
From source file:net.sourceforge.msscodefactory.cfasterisk.v2_1.CFAstSybase.CFAstSybaseSchema.java
public static String getTZTimeString(Calendar val) { if (val == null) { return ("null"); } else {/*from w ww . ja va 2 s . c om*/ Calendar cal; if (val.getTimeZone().equals(getServerTimeZone())) { cal = val; } else { cal = new GregorianCalendar(getServerTimeZone()); cal.setTimeInMillis(val.getTimeInMillis()); } StringBuffer buff = new StringBuffer(); Formatter fmt = new Formatter(buff); fmt.format("%1$04d", cal.get(Calendar.YEAR)); buff.append("-"); fmt.format("%1$02d", cal.get(Calendar.MONTH) + 1); buff.append("-"); fmt.format("%1$02d", cal.get(Calendar.DAY_OF_MONTH)); buff.append("T"); fmt.format("%1$02d", cal.get(Calendar.HOUR_OF_DAY)); buff.append(":"); fmt.format("%1$02d", cal.get(Calendar.MINUTE)); buff.append(":"); fmt.format("%1$02d", cal.get(Calendar.SECOND)); fmt.close(); return (buff.toString()); } }
From source file:net.sourceforge.msscodefactory.cfasterisk.v2_1.CFAstSybase.CFAstSybaseSchema.java
public static String getTZTimestampString(Calendar val) { if (val == null) { return ("null"); } else {// w ww . j av a2 s.co m Calendar cal; if (val.getTimeZone().equals(getServerTimeZone())) { cal = val; } else { cal = new GregorianCalendar(getServerTimeZone()); cal.setTimeInMillis(val.getTimeInMillis()); } StringBuffer buff = new StringBuffer(); Formatter fmt = new Formatter(buff); fmt.format("%1$04d", cal.get(Calendar.YEAR)); buff.append("-"); fmt.format("%1$02d", cal.get(Calendar.MONTH) + 1); buff.append("-"); fmt.format("%1$02d", cal.get(Calendar.DAY_OF_MONTH)); buff.append("T"); fmt.format("%1$02d", cal.get(Calendar.HOUR_OF_DAY)); buff.append(":"); fmt.format("%1$02d", cal.get(Calendar.MINUTE)); buff.append(":"); fmt.format("%1$02d", cal.get(Calendar.SECOND)); fmt.close(); return (buff.toString()); } }
From source file:net.sourceforge.msscodefactory.cfasterisk.v2_1.CFAstSybase.CFAstSybaseSchema.java
public static String getQuotedTZDateString(Calendar val) { if (val == null) { return ("null"); } else {// www .java2s .co m Calendar cal; if (val.getTimeZone().equals(getServerTimeZone())) { cal = val; } else { cal = new GregorianCalendar(getServerTimeZone()); cal.setTimeInMillis(val.getTimeInMillis()); } StringBuffer buff = new StringBuffer("'"); Formatter fmt = new Formatter(buff); fmt.format("%1$04d", cal.get(Calendar.YEAR)); buff.append("-"); fmt.format("%1$02d", cal.get(Calendar.MONTH) + 1); buff.append("-"); fmt.format("%1$02d", cal.get(Calendar.DAY_OF_MONTH)); buff.append("T"); fmt.format("%1$02d", cal.get(Calendar.HOUR_OF_DAY)); buff.append(":"); fmt.format("%1$02d", cal.get(Calendar.MINUTE)); buff.append(":"); fmt.format("%1$02d", cal.get(Calendar.SECOND)); buff.append("'"); fmt.close(); return (buff.toString()); } }
From source file:net.sourceforge.msscodefactory.cfasterisk.v2_1.CFAstSybase.CFAstSybaseSchema.java
public static String getQuotedTZTimeString(Calendar val) { if (val == null) { return ("null"); } else {/*from w w w .java 2s .c o m*/ Calendar cal; if (val.getTimeZone().equals(getServerTimeZone())) { cal = val; } else { cal = new GregorianCalendar(getServerTimeZone()); cal.setTimeInMillis(val.getTimeInMillis()); } StringBuffer buff = new StringBuffer("'"); Formatter fmt = new Formatter(buff); fmt.format("%1$04d", cal.get(Calendar.YEAR)); buff.append("-"); fmt.format("%1$02d", cal.get(Calendar.MONTH) + 1); buff.append("-"); fmt.format("%1$02d", cal.get(Calendar.DAY_OF_MONTH)); buff.append("T"); fmt.format("%1$02d", cal.get(Calendar.HOUR_OF_DAY)); buff.append(":"); fmt.format("%1$02d", cal.get(Calendar.MINUTE)); buff.append(":"); fmt.format("%1$02d", cal.get(Calendar.SECOND)); buff.append("'"); fmt.close(); return (buff.toString()); } }
From source file:net.sourceforge.msscodefactory.cfasterisk.v2_1.CFAstSybase.CFAstSybaseSchema.java
public static String getQuotedTZTimestampString(Calendar val) { if (val == null) { return ("null"); } else {//from w w w . j a va 2s . c om Calendar cal; if (val.getTimeZone().equals(getServerTimeZone())) { cal = val; } else { cal = new GregorianCalendar(getServerTimeZone()); cal.setTimeInMillis(val.getTimeInMillis()); } StringBuffer buff = new StringBuffer("'"); Formatter fmt = new Formatter(buff); fmt.format("%1$04d", cal.get(Calendar.YEAR)); buff.append("-"); fmt.format("%1$02d", cal.get(Calendar.MONTH) + 1); buff.append("-"); fmt.format("%1$02d", cal.get(Calendar.DAY_OF_MONTH)); buff.append("T"); fmt.format("%1$02d", cal.get(Calendar.HOUR_OF_DAY)); buff.append(":"); fmt.format("%1$02d", cal.get(Calendar.MINUTE)); buff.append(":"); fmt.format("%1$02d", cal.get(Calendar.SECOND)); buff.append("'"); fmt.close(); return (buff.toString()); } }
From source file:com.itemanalysis.jmetrik.stats.descriptives.DescriptiveAnalysis.java
public void publishHeader() throws IllegalArgumentException { StringBuilder header = new StringBuilder(); Formatter f = new Formatter(header); String s1 = String.format("%1$tB %1$te, %1$tY %tT", Calendar.getInstance()); int len = 21 + Double.valueOf(Math.floor(Double.valueOf(s1.length()).doubleValue() / 2.0)).intValue(); String dString = ""; try {//from w w w . j ava 2s . co m dString = command.getDataString(); } catch (IllegalArgumentException ex) { throw new IllegalArgumentException(ex); } int len2 = 21 + Double.valueOf(Math.floor(Double.valueOf(dString.length()).doubleValue() / 2.0)).intValue(); f.format("%31s", "DESCRIPTIVE STATISTICS"); f.format("%n"); f.format("%" + len2 + "s", dString); f.format("%n"); f.format("%" + len + "s", s1); f.format("%n"); f.format("%n"); publish(f.toString()); }
From source file:com.itemanalysis.jmetrik.stats.frequency.FrequencyAnalysis.java
public void publishHeader() throws IllegalArgumentException { StringBuilder header = new StringBuilder(); Formatter f = new Formatter(header); String s1 = String.format("%1$tB %1$te, %1$tY %tT", Calendar.getInstance()); int len = 21 + Double.valueOf(Math.floor(Double.valueOf(s1.length()).doubleValue() / 2.0)).intValue(); String dString = ""; try {//www. ja va 2s . com dString = command.getDataString(); } catch (IllegalArgumentException ex) { throw new IllegalArgumentException(ex); } int len2 = 21 + Double.valueOf(Math.floor(Double.valueOf(dString.length()).doubleValue() / 2.0)).intValue(); f.format("%31s", "FREQUENCY ANALYSIS"); f.format("%n"); f.format("%" + len2 + "s", dString); f.format("%n"); f.format("%" + len + "s", s1); f.format("%n"); f.format("%n"); publish(f.toString()); }
From source file:edu.stanford.muse.index.EmailDocument.java
public String getSignature() { StringBuilder sb = new StringBuilder(); StringBuilder timeSB = new StringBuilder(); Formatter formatter = new Formatter(timeSB); if (this.date != null) { GregorianCalendar cc = new GregorianCalendar(); cc.setTime(this.date); formatter.format("%02d:%02d", new Object[] { Integer.valueOf(cc.get(11)), Integer.valueOf(cc.get(12)) }); sb.append("Date: " + cc.get(5) + " " + CalendarUtil.getDisplayMonth(cc) + " " + cc.get(1) + " " + timeSB + "\n"); }// w w w. j a v a2 s . co m formatter.close(); sb.append("From: " + this.getFromString() + "\n"); sb.append("To: " + this.getToString() + "\n"); String cc1 = this.getCcString(); if (!Util.nullOrEmpty(cc1)) { sb.append("Cc: " + cc1 + "\n"); } String bcc = this.getBccString(); if (!Util.nullOrEmpty(bcc)) { sb.append("Bcc: " + bcc + "\n"); } if (this.description == null) { this.description = "<None>"; } sb.append("Subject: " + this.description + "\n"); sb.append("\n"); return sb.toString(); }
From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccPgSql.CFAccPgSqlSchema.java
public static String getQuotedDateString(Calendar val) { if (val == null) { return ("null"); } else {//ww w .j a v a 2 s . c o m StringBuffer buff = new StringBuffer("'"); Formatter fmt = new Formatter(buff); fmt.format("%1$04d", val.get(Calendar.YEAR)); buff.append("-"); fmt.format("%1$02d", val.get(Calendar.MONTH) + 1); buff.append("-"); fmt.format("%1$02d", val.get(Calendar.DAY_OF_MONTH)); buff.append("'"); fmt.close(); return (buff.toString()); } }
From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccPgSql.CFAccPgSqlSchema.java
public static String getQuotedTimeString(Calendar val) { if (val == null) { return ("null"); } else {/*from w w w . j a va 2 s. com*/ StringBuffer buff = new StringBuffer("'"); Formatter fmt = new Formatter(buff); fmt.format("%1$02d", val.get(Calendar.HOUR_OF_DAY)); buff.append(":"); fmt.format("%1$02d", val.get(Calendar.MINUTE)); buff.append(":"); fmt.format("%1$02d", val.get(Calendar.SECOND)); buff.append("'"); fmt.close(); return (buff.toString()); } }