java.text.Format#format ( )源码实例Demo

下面列出了java.text.Format#format ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: Automekanik   文件: TeDhenat.java
public void mbush(){
    try {
        String sql = "select * from Punet where konsumatori = '" + e.getText() + "' order by id asc";
        Connection conn = DriverManager.getConnection(CON_STR, "test", "test");
        Statement stmt = conn.createStatement();
        ResultSet rs = stmt.executeQuery(sql);

        ObservableList<punetTbl> data = FXCollections.observableArrayList();
        Format format = new SimpleDateFormat("dd/MM/yyyy");
        String s = "";
        while (rs.next()){
            s = format.format(rs.getDate("data"));
            data.add(new punetTbl(rs.getInt("id"), rs.getString("lloji"),
                    s, rs.getFloat("qmimi"), rs.getString("pershkrimi"), rs.getString("kryer"), rs.getString("makina")));
        }
        table.getItems().clear();
        table.setItems(data);
        conn.close();
    }catch (Exception ex){
        ex.printStackTrace();
    }
}
 
源代码2 项目: mzmine2   文件: SimpleDataPoint.java
@Override
public String toString() {
  Format mzFormat = MZmineCore.getConfiguration().getMZFormat();
  Format intensityFormat = MZmineCore.getConfiguration().getIntensityFormat();
  String str =
      "m/z: " + mzFormat.format(mz) + ", intensity: " + intensityFormat.format(intensity);
  return str;
}
 
源代码3 项目: MergeProcessor   文件: LogFileHandler.java
private static String getPattern() {
	final Date date = new Date();
	final Format fileDateFormat = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss");
	final String pathLogFileFolder = Configuration.getPathLogFileFolder();
	final Path logFileFolder = Paths.get(pathLogFileFolder);
	if (Files.notExists(logFileFolder)) {
		try {
			Files.createDirectories(logFileFolder);
		} catch (IOException e) {
			Logger.getLogger(LogFileHandler.class.getName()).log(Level.SEVERE, "Could not create log file folder",
					e);
		}
	}
	return pathLogFileFolder + "mp_" + fileDateFormat.format(date) + ".log";
}
 
源代码4 项目: pentaho-reporting   文件: FormatFilter.java
/**
 * Returns the formatted string. The value is read using the data source given and formated using the formatter of
 * this object. The formating is guaranteed to completly form the object to an string or to return the defined
 * NullValue.
 * <p/>
 * If format, datasource or object are null, the NullValue is returned.
 *
 * @param runtime
 *          the expression runtime that is used to evaluate formulas and expressions when computing the value of this
 *          filter.
 * @param element
 * @return The formatted value.
 */
public Object getValue( final ExpressionRuntime runtime, final ReportElement element ) {
  final Format f = getFormatter();
  if ( f == null ) {
    return getNullValue();
  }

  final DataSource ds = getDataSource();
  if ( ds == null ) {
    return getNullValue();
  }

  final Object o = ds.getValue( runtime, element );
  if ( o == null ) {
    return getNullValue();
  }

  if ( cachedResult != null && ( cachedFormat != f ) && ObjectUtilities.equal( cachedValue, o ) ) {
    return cachedResult;
  }

  try {
    cachedResult = f.format( o );
  } catch ( IllegalArgumentException e ) {
    cachedResult = getNullValue();
  }

  cachedFormat = f;
  cachedValue = o;
  return cachedResult;
}
 
源代码5 项目: phoenix   文件: UpgradeUtil.java
public static final String getSysCatalogSnapshotName(long currentSystemTableTimestamp) {
    String tableString = SYSTEM_CATALOG_NAME;
    Format formatter = new SimpleDateFormat("yyyyMMddHHmmss");
    String date = formatter.format(new Date(EnvironmentEdgeManager.currentTimeMillis()));
    String upgradingFrom = getVersion(currentSystemTableTimestamp);
    return "SNAPSHOT_" + tableString + "_" + upgradingFrom + "_TO_" + CURRENT_CLIENT_VERSION + "_" + date;
}
 
@Test
public void test_toFormat_format() throws Exception {
    DateTimeFormatter test = fmt.withLocale(Locale.ENGLISH).withDecimalStyle(DecimalStyle.STANDARD);
    Format format = test.toFormat();
    String result = format.format(LocalDate.of(2008, 6, 30));
    assertEquals(result, "ONE30");
}
 
源代码7 项目: jdk8u-jdk   文件: TCKDateTimeFormatter.java
@Test
public void test_toFormat_format() throws Exception {
    DateTimeFormatter test = fmt.withLocale(Locale.ENGLISH).withDecimalStyle(DecimalStyle.STANDARD);
    Format format = test.toFormat();
    String result = format.format(LocalDate.of(2008, 6, 30));
    assertEquals(result, "ONE30");
}
 
源代码8 项目: threetenbp   文件: TestDateTimeFormatter.java
@Test(expectedExceptions=IllegalArgumentException.class)
public void test_toFormat_format_notCalendrical() throws Exception {
    DateTimeFormatter test = fmt.withLocale(Locale.ENGLISH).withDecimalStyle(DecimalStyle.STANDARD);
    Format format = test.toFormat();
    format.format("Not a Calendrical");
}
 
源代码9 项目: hottub   文件: TCKDateTimeFormatter.java
@Test(expectedExceptions=IllegalArgumentException.class)
public void test_toFormat_format_notTemporal() throws Exception {
    DateTimeFormatter test = fmt.withLocale(Locale.ENGLISH).withDecimalStyle(DecimalStyle.STANDARD);
    Format format = test.toFormat();
    format.format("Not a Temporal");
}
 
源代码10 项目: momo-cloud-permission   文件: DateUtils.java
public static String SYSDATE(String str) {
    Format format = new SimpleDateFormat(str);
    String st = format.format(new Date());
    return st;
}
 
源代码11 项目: j2objc   文件: TCKDateTimeFormatter.java
@Test
public void test_toFormat_Query_format() throws Exception {
    Format format = BASIC_FORMATTER.toFormat();
    String result = format.format(LocalDate.of(2008, 6, 30));
    assertEquals(result, "ONE30");
}
 
源代码12 项目: openjdk-8-source   文件: TCKDateTimeFormatter.java
@Test(expectedExceptions=NullPointerException.class)
public void test_toFormat_format_null() throws Exception {
    DateTimeFormatter test = fmt.withLocale(Locale.ENGLISH).withDecimalStyle(DecimalStyle.STANDARD);
    Format format = test.toFormat();
    format.format(null);
}
 
源代码13 项目: lams   文件: DataFormatter.java
/**
 * Formats the given raw cell value, based on the supplied
 *  format index and string, according to excel style rules.
 * @see #formatCellValue(Cell)
 */
public String formatRawCellContents(double value, int formatIndex, String formatString, boolean use1904Windowing) {
    localeChangedObservable.checkForLocaleChange();
    
    // Is it a date?
    if(DateUtil.isADateFormat(formatIndex,formatString)) {
        if(DateUtil.isValidExcelDate(value)) {
            Format dateFormat = getFormat(value, formatIndex, formatString);
            if(dateFormat instanceof ExcelStyleDateFormatter) {
                // Hint about the raw excel value
                ((ExcelStyleDateFormatter)dateFormat).setDateToBeFormatted(value);
            }
            Date d = DateUtil.getJavaDate(value, use1904Windowing);
            return performDateFormatting(d, dateFormat);
        }
        // RK: Invalid dates are 255 #s.
        if (emulateCSV) {
            return invalidDateTimeString;
        }
    }
    
    // else Number
    Format numberFormat = getFormat(value, formatIndex, formatString);
    if (numberFormat == null) {
        return String.valueOf(value);
    }
    
    // When formatting 'value', double to text to BigDecimal produces more
    // accurate results than double to Double in JDK8 (as compared to
    // previous versions). However, if the value contains E notation, this
    // would expand the values, which we do not want, so revert to
    // original method.
    String result;
    final String textValue = NumberToTextConverter.toText(value);
    if (textValue.indexOf('E') > -1) {
        result = numberFormat.format(new Double(value));
    }
    else {
        result = numberFormat.format(new BigDecimal(textValue));
    }
    // Complete scientific notation by adding the missing +.
    if (result.indexOf('E') > -1 && !result.contains("E-")) {
        result = result.replaceFirst("E", "E+");
    }
    return result;
}
 
源代码14 项目: openjdk-jdk8u   文件: TCKDateTimeFormatter.java
@Test
public void test_toFormat_Query_format() throws Exception {
    Format format = BASIC_FORMATTER.toFormat();
    String result = format.format(LocalDate.of(2008, 6, 30));
    assertEquals(result, "ONE30");
}
 
源代码15 项目: openjdk-jdk9   文件: TCKDateTimeFormatter.java
@Test
public void test_toFormat_Query_format() throws Exception {
    Format format = BASIC_FORMATTER.toFormat();
    String result = format.format(LocalDate.of(2008, 6, 30));
    assertEquals(result, "ONE30");
}
 
源代码16 项目: openjdk-8   文件: TCKDateTimeFormatter.java
@Test(expectedExceptions=IllegalArgumentException.class)
public void test_toFormat_format_notTemporal() throws Exception {
    DateTimeFormatter test = fmt.withLocale(Locale.ENGLISH).withDecimalStyle(DecimalStyle.STANDARD);
    Format format = test.toFormat();
    format.format("Not a Temporal");
}
 
源代码17 项目: openjdk-8   文件: TCKDateTimeFormatter.java
@Test(expectedExceptions=NullPointerException.class)
public void test_toFormat_format_null() throws Exception {
    DateTimeFormatter test = fmt.withLocale(Locale.ENGLISH).withDecimalStyle(DecimalStyle.STANDARD);
    Format format = test.toFormat();
    format.format(null);
}
 
源代码18 项目: jdk8u_jdk   文件: TCKDateTimeFormatter.java
@Test
public void test_toFormat_Query_format() throws Exception {
    Format format = BASIC_FORMATTER.toFormat();
    String result = format.format(LocalDate.of(2008, 6, 30));
    assertEquals(result, "ONE30");
}
 
源代码19 项目: lams   文件: DataFormatter.java
/**
 * Returns the formatted value of an Excel number as a <tt>String</tt>
 * based on the cell's <code>DataFormat</code>. Supported formats include
 * currency, percents, decimals, phone number, SSN, etc.:
 * "61.54%", "$100.00", "(800) 555-1234".
 * <p>
 * Format comes from either the highest priority conditional format rule with a
 * specified format, or from the cell style.
 * 
 * @param cell The cell
 * @param cfEvaluator if available, or null
 * @return a formatted number string
 */
private String getFormattedNumberString(Cell cell, ConditionalFormattingEvaluator cfEvaluator) {

    Format numberFormat = getFormat(cell, cfEvaluator);
    double d = cell.getNumericCellValue();
    if (numberFormat == null) {
        return String.valueOf(d);
    }
    String formatted = numberFormat.format(new Double(d));
    return formatted.replaceFirst("E(\\d)", "E+$1"); // to match Excel's E-notation
}
 
源代码20 项目: lams   文件: AbstractFormatValidator.java
/**
 * <p>Format a value with the specified <code>Format</code>.</p>
 *
 * @param value The value to be formatted.
 * @param formatter The Format to use.
 * @return The formatted value.
 */
protected String format(Object value, Format formatter) {
    return formatter.format(value);
}