PowenKo, Android, Tutorial 008-1, String, String format

August 31, 2011   ·   0 Comments

// 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

shareShare on FacebookShare on Google+Share on LinkedInEmail this to someonePrint this pageBuffer this pageDigg thisFlattr the authorShare on RedditPin on PinterestShare on StumbleUponShare on TumblrTweet about this on Twitter

By


Readers Comments (0)


You must be logged in to post a comment.

PowenKo’s Online Store

powenko_arduinoBook
Android7

Amazon

adsbygoogle

Recent Posts

Categories

Amazon