Monday, March 26, 2012
USSD menu termination value
Unstructured Supplementary Service Data (USSD) menu designing is more considerable. Since, having issues will lead the USSD server to unstable status.
while submitting menu to mobile, these parameter values must be used.
17 - mobile created session termination
2 - application session creation
3 - application session termination
Sunday, March 25, 2012
Remove log files created by log4j
Add following code segment to configure file in log4j.
log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.File=example.log
log4j.appender.R.MaxFileSize=100KB
log4j.appender.R.MaxBackupIndex=7
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%p %t %c - %m%n
MaxBackupIndex will hold maximum number of 7 files in the location that files are created.
Thursday, March 22, 2012
Wireshark packet filtering
Wireshark is a tool for packet filtering in network adapter.
Use following steps to capture packets in Wireshark.
1) Start network interface for capturing for Wireshark Capture/Interfaces
2) Enter filtering in Wireshark filtering option under menu bar
Ex :- ip.addr==192.172.145.26
Above is a filtering packets for ip "192.172.145.26"
3) Right-click on a packet and Follow TCP stream. This gives packet contents.
Use following steps to capture packets in Wireshark.
1) Start network interface for capturing for Wireshark Capture/Interfaces
2) Enter filtering in Wireshark filtering option under menu bar
Ex :- ip.addr==192.172.145.26
Above is a filtering packets for ip "192.172.145.26"
3) Right-click on a packet and Follow TCP stream. This gives packet contents.
Thursday, March 1, 2012
This is a code that can be used to get birth day from National Identity Card in Sri Lanka.
public Calendar getBirthDate(String nic) {
int date = Integer.valueOf(nic.substring(2, 5));
int bdate = 0;
int bmonth = 0;
int byear = Integer.valueOf(nic.substring(0, 2));
if (date > 500) {
date = date - 500;
}
if (date <= 31) {
bdate = date;
bmonth = 1;
}
if (31 < date & date <= 60) {
bdate = date - 31;
bmonth = 2;
}
if (60 < date & date <= 91) {
bdate = date - 60;
bmonth = 3;
}
if (91 < date & date <= 121) {
bdate = date - 91;
bmonth = 4;
}
if (121 < date & date <= 152) {
bdate = date - 121;
bmonth = 5;
}
if (152 < date & date <= 182) {
bdate = date - 152;
bmonth = 6;
}
if (182 < date & date <= 213) {
bdate = date - 182;
bmonth = 7;
}
if (213 < date & date <= 244) {
bdate = date - 213;
bmonth = 8;
}
if (244 < date & date <= 274) {
bdate = date - 244;
bmonth = 9;
}
if (274 < date & date <= 305) {
bdate = date - 274;
bmonth = 10;
}
if (305 < date & date <= 335) {
bdate = date - 305;
bmonth = 11;
}
if (335 < date & date <= 366) {
bdate = date - 335;
bmonth = 12;
}
Calendar calendar = Calendar.getInstance();
calendar.clear();
byear = getYear(byear);
calendar.set(Calendar.YEAR, byear);
calendar.set(Calendar.MONTH, bmonth);
calendar.set(Calendar.DATE, bdate);
return calendar;
}
Calculate age in java
Use following code to calculate the age in java. Input parameter is calendar which contains b'day year, month, day.
public int calculateAge(Calendar bcalendar) {
Calendar today = Calendar.getInstance();
int age = today.get(Calendar.YEAR) - bcalendar.get(Calendar.YEAR);
if (today.get(Calendar.DAY_OF_YEAR) < bcalendar.get(Calendar.DAY_OF_YEAR)) {
age--;
}
return age;
}
Leaf year in java
Following code can be used to find Leaf Year in java.
public boolean isLeafYear(int year) {
boolean leaf = false;
if (year < 100) {
if (year > 40) {
year = year + 1900;
} else {
year = year + 2000;
}
}
if (year % 4 == 0) {
if (year % 100 != 0) {
leaf = true;
} else if (year % 400 == 0) {
leaf = true;
}
}
return leaf;
}
Subscribe to:
Posts (Atom)