List of usage examples for java.util Formatter Formatter
public Formatter(OutputStream os)
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 ww .j a v a2 s.c o m*/ 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()); } }
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 w w. ja v a 2s.c om*/ 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.CFAccPgSql.CFAccPgSqlSchema.java
public static String getQuotedTimestampString(Calendar val) { if (val == null) { return ("null"); } else {/*from w w w . jav a 2s . com*/ 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.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()); } }
From source file:net.sourceforge.msscodefactory.cfasterisk.v2_1.CFAstSybase.CFAstSybaseSchema.java
public static String getTZDateString(Calendar val) { if (val == null) { return ("null"); } else {/*www. j a v a 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.cfacc.v2_0.CFAccDb2LUW.CFAccDb2LUWSchema.java
public static String getQuotedTimeString(Calendar val) { if (val == null) { return ("null"); } else {//from www . j a v a 2 s.co 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:net.sourceforge.msscodefactory.cfasterisk.v2_1.CFAstSybase.CFAstSybaseSchema.java
public static String getTZTimeString(Calendar val) { if (val == null) { return ("null"); } else {/*from ww w .j a v a2 s. 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)); 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 ww. j a v a2 s .com 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:cn.suishen.email.activity.MessageViewFragmentBase.java
/** * @return the given date/time in a human readable form. The returned string always have * month and day (and year if {@code withYear} is set), so is usually long. * Use {@link DateUtils#getRelativeTimeSpanString} instead to save the screen real estate. */// www . j a va2 s . co m private String formatDate(long millis, boolean withYear) { StringBuilder sb = new StringBuilder(); Formatter formatter = new Formatter(sb); DateUtils.formatDateRange(mContext, formatter, millis, millis, DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_ABBREV_ALL | DateUtils.FORMAT_SHOW_TIME | (withYear ? DateUtils.FORMAT_SHOW_YEAR : DateUtils.FORMAT_NO_YEAR)); return sb.toString(); }
From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccDb2LUW.CFAccDb2LUWSchema.java
public static String getQuotedTZDateString(Calendar val) { if (val == null) { return ("null"); } else {/*from ww w .java 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)); 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.cfasterisk.v2_1.CFAstSybase.CFAstSybaseSchema.java
public static String getTZTimestampString(Calendar val) { if (val == null) { return ("null"); } else {// www . j av a 2 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()); } }