// 120.456 –>+120456000

//12.3456789–>  +12345679

// 12.3456789 –> -12345679


package com.powenko.Tutorial_String_format;



import android.app.Activity;

import android.os.Bundle;



public class Tutorial_String_formatActivity extends Activity {

/** Called when the activity is first created. */

@Override

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.main);

double geoLongitude =120.456;

double geoLatitude = -12.3456789;

String m_GPSlong=Convert_double_To9String(geoLongitude);

}

// 120.456 -->+120456000

//12.3456789-->  +012345679

// 12.3456789 --> -012345679


   // sample 
    private  String Convert_double_To9String(double i_value)
    {    
    	 double d = i_value /1000;
    	 String m_GPSlong=String.format("%.9f", d);
         m_GPSlong=m_GPSlong.replace("0.", "");
         if(i_value>0){m_GPSlong="+"+m_GPSlong;}
         return m_GPSlong;
    
    }
    

sample code:

Tutorial_String_format

By admin-powenko

Dr. Powen Ko is a teacher and CEO on LoopTek LLC, and like to teaching. if you need to class, please let PowenKo know, he will love to service and sharing. LoopTek web site is www.looptek.com

Leave a Reply