Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import java.text.DecimalFormatSymbols;
import java.text.NumberFormat;

import java.util.Locale;

public class Main {
    public static boolean isRTL(Locale locale, String symbol) {
        NumberFormat currencyFormat = NumberFormat.getCurrencyInstance(locale);

        // We then tell our formatter to use this symbol.
        DecimalFormatSymbols decimalFormatSymbols = ((java.text.DecimalFormat) currencyFormat)
                .getDecimalFormatSymbols();
        decimalFormatSymbols.setCurrencySymbol(symbol);
        ((java.text.DecimalFormat) currencyFormat).setDecimalFormatSymbols(decimalFormatSymbols);

        String formattedtext = currencyFormat.format(100.0);

        if (formattedtext.startsWith(symbol)) {
            return false;
        } else {
            return true;
        }

        /*
        final int directionality = Character.getDirectionality(String.format(locale,"%s",locale.getDisplayLanguage(locale)).charAt(0));
            
        if ( (directionality == Character.DIRECTIONALITY_RIGHT_TO_LEFT) ||
            (directionality == Character.DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC) )
        {
        return true;
        }
        else
        {
        return false;
        }
         */
    }
}