001package org.kuali.ole.sip2.common; 002 003import java.util.Currency; 004import java.util.Locale; 005 006/** 007 * Created by gayathria on 15/12/14. 008 */ 009public class OLESIP2Util { 010 011 /* 012 Used to get default currency instance 013 */ 014 015 public static Currency getDefaultCurrency() { 016 return Currency.getInstance(Locale.getDefault()); 017 } 018 019 /** 020 * Converts the given boolean to string. false = 0, true = 1. 021 * 022 * @param value boolean value 023 * @return false = 0, true = 1 024 */ 025 public static String bool2Int(boolean value) { 026 if (value) { 027 return "1"; 028 } 029 return "0"; 030 } 031 032 /** 033 * Converts the given boolean to character. false = N, true = Y. 034 * 035 * @param value boolean value 036 * @return false = N, true = Y 037 */ 038 public static String bool2Char(boolean value) { 039 if (value) { 040 return "Y"; 041 } 042 return "N"; 043 } 044 045 /** 046 * Converts the given boolean to character. false = ' ', true = 'Y'. 047 * 048 * @param value boolean value 049 * @return false = ' ', true = 'Y' 050 */ 051 public static String bool2CharEmpty(boolean value) { 052 if (value) { 053 return "Y"; 054 } 055 return " "; 056 } 057 058 /** 059 * Converts the given integer to a fixed length string by adding 060 * leading zeros to the given number that its length equals to the 061 * given length. 062 * 063 * @param value integer value to be converted 064 * @param length length of the output string 065 * @return string presentation of the given integer 066 */ 067 public static String intToFixedLengthString(int value, int length) { 068 return String.format("%0" + length + "d", value); 069 } 070}