List of usage examples for java.lang Long toString
public String toString()
From source file:edu.lternet.pasta.datapackagemanager.DataPackageArchiveTest.java
/** * @throws java.lang.Exception/*from w ww. ja v a2s .com*/ */ @BeforeClass public static void setUpBeforeClass() throws Exception { Options options = null; options = ConfigurationListener.getOptions(); if (options == null) { ConfigurationListener configurationListener = new ConfigurationListener(); configurationListener.initialize(dirPath); options = ConfigurationListener.getOptions(); } tmpDir = options.getOption("datapackagemanager.tmpDir"); if (tmpDir == null || tmpDir.isEmpty()) { String gripe = "Error directory property not set!"; throw new Exception(gripe); } // Set transaction identifier based on wall-clock time Long time = new Date().getTime(); transaction = time.toString(); testArchive = transaction + ".zip"; }
From source file:amplify.NTPClient.java
/** * Process <code>TimeInfo</code> object and print its details. * * @param info <code>TimeInfo</code> object. *///from w w w . jav a 2 s .c o m public static void processResponse(TimeInfo info) { NtpV3Packet message = info.getMessage(); int stratum = message.getStratum(); String refType; if (stratum <= 0) refType = "(Unspecified or Unavailable)"; else if (stratum == 1) refType = "(Primary Reference; e.g., GPS)"; // GPS, radio clock, etc. else refType = "(Secondary Reference; e.g. via NTP or SNTP)"; // stratum should be 0..15... System.out.println(" Stratum: " + stratum + " " + refType); int version = message.getVersion(); int li = message.getLeapIndicator(); System.out.println(" leap=" + li + ", version=" + version + ", precision=" + message.getPrecision()); System.out.println(" mode: " + message.getModeName() + " (" + message.getMode() + ")"); int poll = message.getPoll(); // poll value typically btwn MINPOLL (4) and MAXPOLL (14) System.out.println( " poll: " + (poll <= 0 ? 1 : (int) Math.pow(2, poll)) + " seconds" + " (2 ** " + poll + ")"); double disp = message.getRootDispersionInMillisDouble(); System.out.println(" rootdelay=" + numberFormat.format(message.getRootDelayInMillisDouble()) + ", rootdispersion(ms): " + numberFormat.format(disp)); int refId = message.getReferenceId(); String refAddr = NtpUtils.getHostAddress(refId); String refName = null; if (refId != 0) { if (refAddr.equals("127.127.1.0")) { refName = "LOCAL"; // This is the ref address for the Local Clock } else if (stratum >= 2) { // If reference id has 127.127 prefix then it uses its own reference clock // defined in the form 127.127.clock-type.unit-num (e.g. 127.127.8.0 mode 5 // for GENERIC DCF77 AM; see refclock.htm from the NTP software distribution. if (!refAddr.startsWith("127.127")) { try { InetAddress addr = InetAddress.getByName(refAddr); String name = addr.getHostName(); if (name != null && !name.equals(refAddr)) refName = name; } catch (UnknownHostException e) { // some stratum-2 servers sync to ref clock device but fudge stratum level higher... (e.g. 2) // ref not valid host maybe it's a reference clock name? // otherwise just show the ref IP address. refName = NtpUtils.getReferenceClock(message); } } } else if (version >= 3 && (stratum == 0 || stratum == 1)) { refName = NtpUtils.getReferenceClock(message); // refname usually have at least 3 characters (e.g. GPS, WWV, LCL, etc.) } // otherwise give up on naming the beast... } if (refName != null && refName.length() > 1) refAddr += " (" + refName + ")"; TimeStamp refNtpTime = message.getReferenceTimeStamp(); // Originate Time is time request sent by client (t1) TimeStamp origNtpTime = message.getOriginateTimeStamp(); long destTime = info.getReturnTime(); long localDestTime = System.currentTimeMillis(); // Receive Time is time request received by server (t2) TimeStamp rcvNtpTime = message.getReceiveTimeStamp(); // Transmit time is time reply sent by server (t3) TimeStamp xmitNtpTime = message.getTransmitTimeStamp(); // Destination time is time reply received by client (t4) TimeStamp destNtpTime = TimeStamp.getNtpTime(destTime); info.computeDetails(); // compute offset/delay if not already done Long offsetValue = info.getOffset(); Long delayValue = info.getDelay(); String delay = (delayValue == null) ? "N/A" : delayValue.toString(); String offset = (offsetValue == null) ? "N/A" : offsetValue.toString(); clockOffset = offsetValue != null ? offsetValue.longValue() : 0L; System.out.println(" Reference Identifier:\t" + refAddr); System.out.println(" Reference Timestamp:\t" + refNtpTime + " " + refNtpTime.toDateString()); System.out.println(" Originate Timestamp:\t" + origNtpTime + " " + origNtpTime.toDateString()); System.out.println(" Receive Timestamp:\t" + rcvNtpTime + " " + rcvNtpTime.toDateString()); System.out.println(" Transmit Timestamp:\t" + xmitNtpTime + " " + xmitNtpTime.toDateString()); System.out.println(" Destination Timestamp:\t" + destNtpTime + " " + destNtpTime.toDateString()); System.out.println(" Roundtrip delay(ms)=" + delay + ", clock offset(ms)=" + offset); // offset in ms }
From source file:com.amplify.gcm.hack.NTPClient.java
/** * Process <code>TimeInfo</code> object and print its details. * * @param info <code>TimeInfo</code> object. *///from w w w . j a va2s . c om public static void processResponse(TimeInfo info) { NtpV3Packet message = info.getMessage(); int stratum = message.getStratum(); String refType; if (stratum <= 0) refType = "(Unspecified or Unavailable)"; else if (stratum == 1) refType = "(Primary Reference; e.g., GPS)"; // GPS, radio clock, etc. else refType = "(Secondary Reference; e.g. via NTP or SNTP)"; // stratum should be 0..15... System.out.println(" Stratum: " + stratum + " " + refType); int version = message.getVersion(); int li = message.getLeapIndicator(); System.out.println(" leap=" + li + ", version=" + version + ", precision=" + message.getPrecision()); System.out.println(" mode: " + message.getModeName() + " (" + message.getMode() + ")"); int poll = message.getPoll(); // poll value typically btwn MINPOLL (4) and MAXPOLL (14) System.out.println( " poll: " + (poll <= 0 ? 1 : (int) Math.pow(2, poll)) + " seconds" + " (2 ** " + poll + ")"); double disp = message.getRootDispersionInMillisDouble(); System.out.println(" rootdelay=" + numberFormat.format(message.getRootDelayInMillisDouble()) + ", rootdispersion(ms): " + numberFormat.format(disp)); int refId = message.getReferenceId(); String refAddr = NtpUtils.getHostAddress(refId); String refName = null; if (refId != 0) { if (refAddr.equals("127.127.1.0")) { refName = "LOCAL"; // This is the ref address for the Local Clock } else if (stratum >= 2) { // If reference id has 127.127 prefix then it uses its own reference clock // defined in the form 127.127.clock-type.unit-num (e.g. 127.127.8.0 mode 5 // for GENERIC DCF77 AM; see refclock.htm from the NTP software distribution. if (!refAddr.startsWith("127.127")) { try { InetAddress addr = InetAddress.getByName(refAddr); String name = addr.getHostName(); if (name != null && !name.equals(refAddr)) refName = name; } catch (UnknownHostException e) { // some stratum-2 servers sync to ref clock device but fudge stratum level higher... (e.g. 2) // ref not valid host maybe it's a reference clock name? // otherwise just show the ref IP address. refName = NtpUtils.getReferenceClock(message); } } } else if (version >= 3 && (stratum == 0 || stratum == 1)) { refName = NtpUtils.getReferenceClock(message); // refname usually have at least 3 characters (e.g. GPS, WWV, LCL, etc.) } // otherwise give up on naming the beast... } if (refName != null && refName.length() > 1) refAddr += " (" + refName + ")"; TimeStamp refNtpTime = message.getReferenceTimeStamp(); // Originate Time is time request sent by client (t1) TimeStamp origNtpTime = message.getOriginateTimeStamp(); long destTime = info.getReturnTime(); long localDestTime = System.currentTimeMillis(); // Receive Time is time request received by server (t2) TimeStamp rcvNtpTime = message.getReceiveTimeStamp(); // Transmit time is time reply sent by server (t3) TimeStamp xmitNtpTime = message.getTransmitTimeStamp(); // Destination time is time reply received by client (t4) TimeStamp destNtpTime = TimeStamp.getNtpTime(destTime); info.computeDetails(); // compute offset/delay if not already done Long offsetValue = info.getOffset(); Long delayValue = info.getDelay(); String delay = (delayValue == null) ? "N/A" : delayValue.toString(); String offset = (offsetValue == null) ? "N/A" : offsetValue.toString(); clockOffset = offsetValue != null ? offsetValue.longValue() : 0L; Log.i(TAG, " Reference Identifier:\t" + refAddr); Log.i(TAG, " Reference Timestamp:\t" + refNtpTime + " " + refNtpTime.toDateString()); Log.i(TAG, " Originate Timestamp:\t" + origNtpTime + " " + origNtpTime.toDateString()); Log.i(TAG, " Receive Timestamp:\t" + rcvNtpTime + " " + rcvNtpTime.toDateString()); Log.i(TAG, " Transmit Timestamp:\t" + xmitNtpTime + " " + xmitNtpTime.toDateString()); Log.i(TAG, " Destination Timestamp:\t" + destNtpTime + " " + destNtpTime.toDateString()); Log.i(TAG, " Roundtrip delay(ms)=" + delay + ", clock offset(ms)=" + offset); }
From source file:mitm.common.properties.HierarchicalPropertiesUtils.java
/** * Sets the long property named propertyName. *//* w w w . ja v a 2s . com*/ public static void setLong(HierarchicalProperties properties, String propertyName, Long value, boolean encrypt) throws HierarchicalPropertiesException { properties.setProperty(propertyName, value != null ? value.toString() : null, encrypt); }
From source file:edu.lternet.pasta.datapackagemanager.DataPackageErrorTest.java
/** * @throws java.lang.Exception/*from ww w . j a v a 2 s .c o m*/ */ @BeforeClass public static void setUpBeforeClass() throws Exception { Options options = null; options = ConfigurationListener.getOptions(); if (options == null) { ConfigurationListener configurationListener = new ConfigurationListener(); configurationListener.initialize(dirPath); options = ConfigurationListener.getOptions(); } errorDir = options.getOption("datapackagemanager.errorDir"); if (errorDir == null || errorDir.isEmpty()) { String gripe = "Error directory property not set!"; throw new Exception(gripe); } // Set transaction identifier based on wall-clock time Long time = new Date().getTime(); transaction = time.toString(); }
From source file:com.bhbsoft.videoconference.record.convert.util.FlvFileHelper.java
public static File getStreamsSubDir(Long id) { return getDir(getStreamsDir(), id.toString()); }
From source file:org.openmhealth.shim.ihealth.mapper.IHealthDataPointMapper.java
/** * Get an effective time frame based on the measurement date/time information in the list entry node. The effective * time frame is set as a single point in time using an OffsetDateTime. This method does not get effective time * frame as a time interval./*from w ww . j a va 2 s. co m*/ * * @param listEntryNode A single node from the response result array. */ protected static Optional<TimeFrame> getEffectiveTimeFrameAsDateTime(JsonNode listEntryNode) { Optional<Long> weirdSeconds = asOptionalLong(listEntryNode, "MDate"); if (!weirdSeconds.isPresent()) { return Optional.empty(); } ZoneOffset zoneOffset = null; // if the time zone is a JSON string if (asOptionalString(listEntryNode, "TimeZone").isPresent() && !asOptionalString(listEntryNode, "TimeZone").get().isEmpty()) { zoneOffset = ZoneOffset.of(asOptionalString(listEntryNode, "TimeZone").get()); } // if the time zone is an JSON integer else if (asOptionalLong(listEntryNode, "TimeZone").isPresent()) { Long timeZoneOffsetValue = asOptionalLong(listEntryNode, "TimeZone").get(); String timeZoneString = timeZoneOffsetValue.toString(); // Zone offset cannot parse a positive string offset that's missing a '+' sign (i.e., "0200" vs "+0200") if (timeZoneOffsetValue >= 0) { timeZoneString = "+" + timeZoneString; } zoneOffset = ZoneOffset.of(timeZoneString); } if (zoneOffset == null) { return Optional.empty(); } return Optional.of(new TimeFrame(getDateTimeWithCorrectOffset(weirdSeconds.get(), zoneOffset))); }
From source file:com.nridge.core.base.std.XMLUtl.java
public static void setAttrLongValue(Element anElement, String aName, long aValue) { Long longObject; if (StringUtils.isNotEmpty(aName)) { longObject = aValue;//from w w w . ja va 2 s . c om anElement.setAttribute(aName, longObject.toString()); } }
From source file:com.invbf.sistemagestionmercadeo.reportes.ReportCreator.java
private static String getAsString(Object o) { String numberseparated = ""; String iPartS = ""; if (o instanceof Double) { double number = (Double) o; Long iPart = (long) number; iPartS = iPart.toString(); } else if (o instanceof Float) { float number = (Float) o; Long iPart = (long) number; iPartS = iPart.toString();//from w ww . jav a2 s . c om } else { String number = (String) o; System.out.println("numero " + number); if (number.lastIndexOf(".") != -1) { iPartS = number.substring(0, number.lastIndexOf(".")); } else { iPartS = number; } } boolean milesima = true; while (true) { System.out.println("asi va el numero " + numberseparated); System.out.println("y queda esto " + iPartS); if (iPartS.length() == 0) { break; } else if (iPartS.length() <= 3) { numberseparated = iPartS + numberseparated; iPartS = ""; } else { if (milesima) { numberseparated = "." + iPartS.substring(iPartS.length() - 3) + numberseparated; iPartS = iPartS.substring(0, iPartS.length() - 3); milesima = false; } else { numberseparated = "'" + iPartS.substring(iPartS.length() - 3) + numberseparated; iPartS = iPartS.substring(0, iPartS.length() - 3); milesima = true; } } } System.out.println("asi quedo sin parte real " + numberseparated); System.out.println("asi quedo con parte real " + numberseparated); System.out.println(); System.out.println(); return numberseparated; }
From source file:com.owncloud.android.lib.testclient.TestActivity.java
private static String getFileLastModifTimeStamp(String storagePath) { File file = new File(storagePath); Long timeStampLong = file.lastModified() / 1000; return timeStampLong.toString(); }