コード例 #1
0
  /** Convert to a String */
  String rrToString() {
    StringBuffer sb = new StringBuffer();
    long temp;
    char direction;

    /* Latitude */
    sb.append(positionToString(latitude, 'N', 'S'));
    sb.append(" ");

    /* Latitude */
    sb.append(positionToString(longitude, 'E', 'W'));
    sb.append(" ");

    /* Altitude */
    sb.append(w2.format((double) (altitude - 10000000) / 100));
    sb.append("m ");

    /* Size */
    sb.append(w2.format((double) size / 100));
    sb.append("m ");

    /* Horizontal precision */
    sb.append(w2.format((double) hPrecision / 100));
    sb.append("m ");

    /* Vertical precision */
    sb.append(w2.format((double) vPrecision / 100));
    sb.append("m");

    return sb.toString();
  }
コード例 #2
0
  static {
    w2 = new DecimalFormat();
    w2.setMaximumFractionDigits(2);
    w2.setGroupingUsed(false);

    w3 = new DecimalFormat();
    w3.setMaximumFractionDigits(3);
    w3.setGroupingUsed(false);
  }
コード例 #3
0
  private String positionToString(long value, char pos, char neg) {
    StringBuffer sb = new StringBuffer();
    char direction;

    long temp = value - (1L << 31);
    if (temp < 0) {
      temp = -temp;
      direction = neg;
    } else direction = pos;

    sb.append(temp / (3600 * 1000)); /* degrees */
    temp = temp % (3600 * 1000);
    sb.append(" ");

    sb.append(temp / (60 * 1000)); /* minutes */
    temp = temp % (60 * 1000);
    sb.append(" ");

    sb.append(w3.format(((double) temp) / 1000)); /* seconds */
    sb.append(" ");

    sb.append(direction);

    return sb.toString();
  }
コード例 #4
0
ファイル: SIGRecord.java プロジェクト: lemmy/dnsjava
  static String formatDate(Date d) {
    Calendar c = new GregorianCalendar(TimeZone.getTimeZone("UTC"));
    StringBuffer sb = new StringBuffer();
    NumberFormat w4 = new DecimalFormat();
    w4.setMinimumIntegerDigits(4);
    w4.setGroupingUsed(false);
    NumberFormat w2 = new DecimalFormat();
    w2.setMinimumIntegerDigits(2);

    c.setTime(d);
    sb.append(w4.format(c.get(c.YEAR)));
    sb.append(w2.format(c.get(c.MONTH) + 1));
    sb.append(w2.format(c.get(c.DAY_OF_MONTH)));
    sb.append(w2.format(c.get(c.HOUR_OF_DAY)));
    sb.append(w2.format(c.get(c.MINUTE)));
    sb.append(w2.format(c.get(c.SECOND)));
    return sb.toString();
  }