簡體   English   中英

對如何在Java中應用格式感到困惑

[英]Confused about How to Apply Format in Java

我有一個非常基本的Timer應用程序。我需要獲得從開始到停止之間的時間。所以我試圖格式化返回值。但是我得到了這個輸出

-1421687075,731

我在這里做錯了什么

public void actionPerformed(ActionEvent e) {
        if(e.getSource()==btnStartt){

            sum=0;
            count=0;
            pbShow.setMaximum(Integer.parseInt(txtenter.getText()));
            timer.start();
            now=System.currentTimeMillis();



        }
        if(e.getSource()==btnStop){

            timer.stop();
            now=System.currentTimeMillis();
            pbShow.setValue(0);
            count=0;
            Format formater=new DecimalFormat("#.#####");


        System.out.println(formater.format((end-now)/1000d));

您的代碼不會編譯,但是基於那里,我現在假設您的語句now=System.currentTimeMillis(); 第二個if塊應為: end=System.currentTimeMillis();

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM