List of usage examples for java.text NumberFormat getInstance
public static final NumberFormat getInstance()
From source file:com.alibaba.druid.benckmark.pool.Oracle_Case0.java
private void p0(DataSource dataSource, String name) throws SQLException { long startMillis = System.currentTimeMillis(); long startYGC = TestUtil.getYoungGC(); long startFullGC = TestUtil.getFullGC(); final int COUNT = 1000 * 1; for (int i = 0; i < COUNT; ++i) { Connection conn = dataSource.getConnection(); PreparedStatement stmt = conn.prepareStatement("SELECT 1 FROM DUAL"); ResultSet rs = stmt.executeQuery(); rs.next();//from w w w . ja v a 2 s. co m rs.close(); stmt.close(); conn.close(); } long millis = System.currentTimeMillis() - startMillis; long ygc = TestUtil.getYoungGC() - startYGC; long fullGC = TestUtil.getFullGC() - startFullGC; System.out.println(name + " millis : " + NumberFormat.getInstance().format(millis) + ", YGC " + ygc + " FGC " + fullGC); }
From source file:com.talent.aio.examples.im.client.ui.JFrameMain.java
public static void updateSentLabel() { if (isNeedUpdateSentCount) { isNeedUpdateSentCount = false;/*from ww w . j a v a 2 s .co m*/ NumberFormat numberFormat = NumberFormat.getInstance(); ClientGroupContext<Object, ImPacket, Object> clientGroupContext = imClientStarter .getClientGroupContext(); GroupStat groupStat = clientGroupContext.getGroupStat(); instance.sentLabel.setText(numberFormat.format(groupStat.getSentPacket().get()) + "?" + numberFormat.format(groupStat.getSentBytes().get()) + "B"); } }
From source file:com.googlecode.vfsjfilechooser2.accessories.connection.ConnectionDialog.java
private void initCenterPanelComponents() { // create the panel this.centerPanel = new JPanel(new GridBagLayout()); this.centerPanel.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3)); // create the components this.hostnameLabel = new JLabel(VFSResources.getMessage("VFSJFileChooser.hostnameLabelText")); this.hostnameLabel.setForeground(Color.RED); this.hostnameTextField = new JTextField(25); this.portLabel = new JLabel(VFSResources.getMessage("VFSJFileChooser.portLabelText")); this.portTextField = new JFormattedTextField(NumberFormat.getInstance()); this.isPortTextFieldDirty = false; this.protocolLabel = new JLabel(VFSResources.getMessage("VFSJFileChooser.protocolLabelText")); this.protocolModel = new DefaultComboBoxModel(Protocol.values()); this.protocolList = new JComboBox(protocolModel); this.protocolList.setRenderer(new ProtocolRenderer()); this.usernameLabel = new JLabel(VFSResources.getMessage("VFSJFileChooser.usernameLabelText")); this.usernameTextField = new JTextField(20); this.passwordLabel = new JLabel(VFSResources.getMessage("VFSJFileChooser.passwordLabelText")); this.passwordTextField = new JPasswordField(12); this.defaultRemotePathLabel = new JLabel(VFSResources.getMessage("VFSJFileChooser.pathLabelText")); this.defaultRemotePathTextField = new JTextField(20); // Add the components to the panel makeGridPanel(new Component[] { hostnameLabel, hostnameTextField, portLabel, portTextField, protocolLabel, protocolList, usernameLabel, usernameTextField, passwordLabel, passwordTextField, defaultRemotePathLabel, defaultRemotePathTextField }); }
From source file:com.alibaba.druid.benckmark.pool.Case_Concurrent_50.java
private void p0(final DataSource dataSource, String name) throws Exception { long startMillis = System.currentTimeMillis(); long startYGC = TestUtil.getYoungGC(); long startFullGC = TestUtil.getFullGC(); final CountDownLatch endLatch = new CountDownLatch(THREAD_COUNT); for (int i = 0; i < THREAD_COUNT; ++i) { Thread thread = new Thread() { public void run() { try { for (int i = 0; i < COUNT; ++i) { Connection conn = dataSource.getConnection(); Statement stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery("SELECT 1"); Thread.sleep(0, 1000 * 100); rs.close();/*from w w w . ja va2 s .c om*/ stmt.close(); conn.close(); } } catch (Exception e) { e.printStackTrace(); } finally { endLatch.countDown(); } } }; thread.start(); } endLatch.await(); long millis = System.currentTimeMillis() - startMillis; long ygc = TestUtil.getYoungGC() - startYGC; long fullGC = TestUtil.getFullGC() - startFullGC; System.out.println(name + " millis : " + NumberFormat.getInstance().format(millis) + ", YGC " + ygc + " FGC " + fullGC); }
From source file:com.alibaba.druid.benckmark.pool.Oracle_Case3.java
private void p0(final DataSource dataSource, String name, int threadCount) throws Exception { final CountDownLatch startLatch = new CountDownLatch(1); final CountDownLatch endLatch = new CountDownLatch(threadCount); for (int i = 0; i < threadCount; ++i) { Thread thread = new Thread() { public void run() { try { startLatch.await();//from w w w. jav a2 s. c o m for (int i = 0; i < LOOP_COUNT; ++i) { Connection conn = dataSource.getConnection(); Statement stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery("SELECT 1 FROM DUAL"); rs.next(); // Assert.isTrue(!rs.isClosed()); rs.close(); // Assert.isTrue(!stmt.isClosed()); stmt.close(); Assert.isTrue(stmt.isClosed()); conn.close(); } } catch (Exception ex) { ex.printStackTrace(); } endLatch.countDown(); } }; thread.start(); } long startMillis = System.currentTimeMillis(); long startYGC = TestUtil.getYoungGC(); long startFullGC = TestUtil.getFullGC(); startLatch.countDown(); endLatch.await(); long millis = System.currentTimeMillis() - startMillis; long ygc = TestUtil.getYoungGC() - startYGC; long fullGC = TestUtil.getFullGC() - startFullGC; System.out.println("thread " + threadCount + " " + name + " millis : " + NumberFormat.getInstance().format(millis) + ", YGC " + ygc + " FGC " + fullGC); }
From source file:com.manpowergroup.cn.icloud.util.Case0.java
private void p0(DataSource dataSource, String name) throws SQLException { long startMillis = System.currentTimeMillis(); long startYGC = TestUtil.getYoungGC(); long startFullGC = TestUtil.getFullGC(); for (int i = 0; i < COUNT; ++i) { Connection conn = dataSource.getConnection(); Statement stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery("SELECT 1"); rs.close();/*w w w.j av a 2 s . c o m*/ stmt.close(); conn.close(); } long millis = System.currentTimeMillis() - startMillis; long ygc = TestUtil.getYoungGC() - startYGC; long fullGC = TestUtil.getFullGC() - startFullGC; System.out.println(name + " millis : " + NumberFormat.getInstance().format(millis) + ", YGC " + ygc + " FGC " + fullGC); }
From source file:io.plaidapp.ui.PlayerSheet.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.player_sheet); ButterKnife.bind(this); final Intent intent = getIntent(); final @PlayerSheetMode int mode = intent.getIntExtra(EXTRA_MODE, -1); switch (mode) { case MODE_SHOT_LIKES: shot = intent.getParcelableExtra(EXTRA_SHOT); title.setText(getResources().getQuantityString(R.plurals.fans, (int) shot.likes_count, NumberFormat.getInstance().format(shot.likes_count))); dataManager = new ShotLikesDataManager(this, shot.id) { @Override/*from www . jav a2s .com*/ public void onDataLoaded(List<Like> likes) { adapter.addItems(likes); } }; break; case MODE_FOLLOWERS: player = intent.getParcelableExtra(EXTRA_USER); title.setText(getResources().getQuantityString(R.plurals.follower_count, player.followers_count, NumberFormat.getInstance().format(player.followers_count))); dataManager = new FollowersDataManager(this, player.id) { @Override public void onDataLoaded(List<Follow> followers) { adapter.addItems(followers); } }; break; default: throw new IllegalArgumentException("Unknown launch mode."); } bottomSheet.registerCallback(new BottomSheet.Callbacks() { @Override public void onSheetDismissed() { finishAfterTransition(); } @Override public void onSheetPositionChanged(int sheetTop, boolean interacted) { if (interacted && close.getVisibility() != View.VISIBLE) { close.setVisibility(View.VISIBLE); close.setAlpha(0f); close.animate().alpha(1f).setDuration(400L) .setInterpolator(getLinearOutSlowInInterpolator(PlayerSheet.this)).start(); } if (sheetTop == 0) { showClose(); } else { showDown(); } } }); layoutManager = new LinearLayoutManager(this); playerList.setLayoutManager(layoutManager); playerList.setItemAnimator(new SlideInItemAnimator()); adapter = new PlayerAdapter(this); dataManager.registerCallback(adapter); playerList.setAdapter(adapter); playerList.addOnScrollListener(new InfiniteScrollListener(layoutManager, dataManager) { @Override public void onLoadMore() { dataManager.loadData(); } }); playerList.addOnScrollListener(titleElevation); dataManager.loadData(); // kick off initial load }
From source file:com.cloudera.sqoop.util.AppendUtils.java
/** * Move files from source to target using a specified starting partition. *///w w w. ja v a2 s . c o m private void moveFiles(FileSystem fs, Path sourceDir, Path targetDir, int partitionStart) throws IOException { NumberFormat numpart = NumberFormat.getInstance(); numpart.setMinimumIntegerDigits(PARTITION_DIGITS); numpart.setGroupingUsed(false); Pattern patt = Pattern.compile("part.*-([0-9][0-9][0-9][0-9][0-9]).*"); FileStatus[] tempFiles = fs.listStatus(sourceDir); if (null == tempFiles) { // If we've already checked that the dir exists, and now it can't be // listed, this is a genuine error (permissions, fs integrity, or other). throw new IOException("Could not list files from " + sourceDir); } // Move and rename files & directories from temporary to target-dir thus // appending file's next partition for (FileStatus fileStat : tempFiles) { if (!fileStat.isDir()) { // Move imported data files String filename = fileStat.getPath().getName(); Matcher mat = patt.matcher(filename); if (mat.matches()) { String name = getFilename(filename); String fileToMove = name.concat(numpart.format(partitionStart++)); String extension = getFileExtension(filename); if (extension != null) { fileToMove = fileToMove.concat(extension); } LOG.debug("Filename: " + filename + " repartitioned to: " + fileToMove); fs.rename(fileStat.getPath(), new Path(targetDir, fileToMove)); } } else { // Move directories (_logs & any other) String dirName = fileStat.getPath().getName(); Path path = new Path(targetDir, dirName); int dirNumber = 0; while (fs.exists(path)) { path = new Path(targetDir, dirName.concat("-").concat(numpart.format(dirNumber++))); } LOG.debug("Directory: " + dirName + " renamed to: " + path.getName()); fs.rename(fileStat.getPath(), path); } } }
From source file:com.googlecode.logVisualizer.chart.turnrundownGantt.GanttChartBuilder.java
private JFreeChart createChart(final SlidingGanttCategoryDataset dataset) { this.dataset = dataset; final JFreeChart chart = ChartFactory.createGanttChart(getTitle(), null, null, dataset, false, true, false); final CategoryPlot plot = (CategoryPlot) chart.getPlot(); final CategoryItemRenderer renderer = plot.getRenderer(); plot.getDomainAxis().setMaximumCategoryLabelWidthRatio(0.15f); plot.setRangeAxis(new FixedZoomNumberAxis()); plot.getRangeAxis().setStandardTickUnits(NumberAxis.createIntegerTickUnits()); plot.getRangeAxis().setAutoRange(false); plot.setRangeGridlinePaint(Color.black); setBarShadowVisible(chart, false);//from w w w .ja va 2s. com for (final AreaInterval ai : ((TurnRundownDataset) dataset.getUnderlyingDataset()).getDataset()) if (lastTurnNumber < ai.getEndTurn()) lastTurnNumber = ai.getEndTurn(); addDayMarkers(plot); addLevelMarkers(plot); addFamiliarMarkers(plot); plot.getRangeAxis().setUpperBound(lastTurnNumber + 10); renderer.setSeriesPaint(0, Color.red); renderer.setBaseToolTipGenerator( new IntervalCategoryToolTipGenerator("{1}, {3} - {4}", NumberFormat.getInstance())); return chart; }
From source file:net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.DataTypeBigDecimal.java
/** * Constructor - save the data needed by this data type. *//*from w w w .j a va2 s .c o m*/ public DataTypeBigDecimal(JTable table, ColumnDisplayDefinition colDef) { _table = table; _colDef = colDef; _isNullable = colDef.isNullable(); _precision = colDef.getPrecision(); _scale = colDef.getScale(); _numberFormat = NumberFormat.getInstance(); // If we use _scale here some number displays go crazy. //_numberFormat.setMaximumFractionDigits(_scale); _numberFormat.setMaximumFractionDigits(maximumFractionDigits); _numberFormat.setMinimumFractionDigits(0); }