/** * @param ipV4Text - ip v4 address e.g. 10.0.10.1 * @return */ String convertIPtoBin(String ipV4Text) { String[] addrArray = ipV4Text.split("\\."); long num = 0; for (int i = 0; i < addrArray.length; i++) { System.out.println("(" + i + ") " + addrArray[i]); int power = 3 - i; num += ((Integer.parseInt(addrArray[i]) % 256 * Math.pow(256, power))); } System.out.println("ip: " + ipV4Text + " = " + num + "; 0x" + Long.toHexString(num)); return Long.toHexString( num); // do not prefix "0x", leave it at Seagull script as extra syntax will be required // e.g. 0x0001[ip] }
List<String> calc(String str_date) { long myDateMillis = 0; long d1900 = 0; Date myDate = null; List<String> ls = new ArrayList<String>(); try { myDate = parseDate(str_date); System.out.println(printDate(myDate) + " // orig date"); // Calendar cal = Calendar.getInstance(); cal.setTime(myDate); cal.add(Calendar.HOUR, -5); cal.add(Calendar.MINUTE, -30); myDate = cal.getTime(); // Update date to -5:30 // Calendar c = Calendar.getInstance(); c.clear(); c.setTimeZone(TimeZone.getTimeZone("GMT")); c.set(1900, 0, 1, 0, 0, 0); d1900 = c.getTimeInMillis(); System.out.println(printDate(c.getTime()) + " // 1900"); for (int i = 0; i < 10; i++) { long durInSec = (cal.getTimeInMillis() - d1900) / 1000; String durInSecHex = Long.toHexString(durInSec); System.out.println(printDate(cal.getTime()) + " " + durInSec + " " + durInSecHex); ls.add(durInSecHex); cal.add(Calendar.SECOND, +50); } } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } return ls; } // DateCalc constructor