android 格林尼治时间格式转换 数字表达形式 横线

     项目接着推进的时候,界面上的金额需要表示如下:500,00,还有100,00.00

     解决方案是:

          网上的方案如下:

java中对于字符串(正负数字)进行展示的时候,展示成千分位格式和保留小数位。解决的方法有两种,一种是后台java进行处理,另一种是前台js处理。

1种方法:工具类(只适合不带正负号的数字的字符串),此方法是保留两位小数位,整数位是千分位格式

//千分位方法

   public static String fmtMicrometer(String text) 

   { 

       DecimalFormat df = null; 

       if(text.indexOf(".") > 0) 

       { 

           if(text.length() - text.indexOf(".")-1 == 0) 

           { 

                df = new DecimalFormat("###,##0."); 

           }else if(text.length() - text.indexOf(".")-1 == 1) 

           { 

                df = newDecimalFormat("###,##0.0"); 

           }else 

           { 

                df = newDecimalFormat("###,##0.00"); 

            } 

       }else  

       { 

           df = new DecimalFormat("###,##0"); 

       } 

       double number = 0.0; 

       try { 

            number = Double.parseDouble(text); 

       } catch (Exception e) { 

           number = 0.0; 

       } 

       return df.format(number); 

    }

 

如果带正负号如String s = -38475000.9098

if(s.startsWith("-")){

                            Strings=this.fmtMicrometer(strResults.substring(1, strResults.length()));

                            System.out.println(s);

                        }

 

//得到的结果就是-38,475,000.90


   //千分位表示:500,00
NumberFormat formatter = new DecimalFormat("###,###");  
   String d = formatter.format((maps.get(position).get("country")
.toString()))+""; 
viewHolder.country.setText(d);

if(Double.parseDouble(maps.get(position).get("country1").toString()) > 0.000001 ){
NumberFormat format = new DecimalFormat("###,##0.00");  
   String d1 = formatter.format(Double.parseDouble(maps.get(position).
    get("country1").toString()))+"";

/*viewHolder.country1.setText(maps.get(position).get("country1")
.toString());*/
viewHolder.country1.setTextColor(0xFF42A881);
}else{
NumberFormat format = new DecimalFormat("###,##0.00");  
   String d1 = formatter.format(Double.parseDouble(maps.get(position).
    get("country1").toString()))+"";
/*viewHolder.country1.setText(maps.get(position).get("country1")
.toString());*/
viewHolder.country1.setTextColor(0xFFFF0000);
}

     


      2.我试过了下列是最简便的方式转换格林尼治时间:

SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");

String yymmdd = simpleDateFormat.format(trade[i].getOpenTime()); // 2012-08-29 02:45:00


      3.界面上使控件之间有间距:android:layout_marginTop="5dp"

      4.在界面显示横线:<View
        android:layout_width="wrap_content"
        android:layout_height="1.2px"
        android:background="#FFFFFF"
        android:layout_marginTop="10dp"
         />

        虽然能显示横线,但长度填满屏幕,需要和按钮一致,解决如下:

    <View
        android:layout_width="wrap_content"
        android:layout_height="1.2px"
        android:layout_marginLeft="14dp"
        android:layout_marginRight="14dp"
        android:layout_marginBottom="5dp"
        android:layout_marginTop="5dp"
        android:background="@color/white" />


     5.遇到这样一个错误,进入软件任意一个界面,点击back键,再次进入主界面,点击该fragment,弹出错误:

弹出的进度框报异常:

 

android.view.WindowManager$BadTokenException: Unable to add window  

      我错处的代码是这样的:

       progressDialog.show();

       private void initProgress() {
progressDialog = DialogManager.showProgressDialog(getActivity().getParent(), "",
"數據加載中...", DialogType.OrderHis);
}

    解决方案是:

AlertDialog是属于Acitivity的,当Activity销毁的时候它也必须销毁,所以这里我们指定是Activity的Context。

       

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值