Sunday, February 27, 2011

Konversi Teks ke Numerik dengan Apache Commons

Anda ingin mengkonversi objek String / teks ke berbagai class numerik dan menemui kesulitan harus menangani exception dimana-mana sebelumnya ? Hal itu yang sering saya temui juga dalam menangani berbagai kompleksitas tipe data seperti ini.

Beruntung pustaka Apache commons memiliki utilitas yang memudahkan kita melakukan hal tersebut. Lebih spesifiknya terdapat di BeanUtils.

Berikut adalah contoh code penggunaan konversi menggunakan pustaka tersebut.
import org.apache.commons.beanutils.ConvertUtils;

public class konversi {

 public static void main(String[] args) {
  String angka1 = "123";
  String angka2 = "123.456";
  
  Integer hasil1 = (Integer) ConvertUtils.convert(angka1, Integer.class);
  Float   hasil2 = (Float) ConvertUtils.convert(angka2, Float.class);
  Double hasil3 = (Double) ConvertUtils.convert(angka2, Double.class);

  System.out.println(hasil1);
  System.out.println(hasil2);
  System.out.println(hasil3);
 }

Sunday, December 26, 2010

Deploy Google App Engine Application in Eclipse

So, how do we deploy our GAE using Google Plugins for Eclipse ?

First, edit the configuration file : appengine-web.xml. See the documentation for this file here.

After that, deploy the appengine by clicking the "Deploy App Engine Project" button. Fill in the application name, user and password in popup dialog and click "Deploy"


Done.