Exemplo n.º 1
1
 private String getDate(String timeStampStr, String format) {
   DateFormat formatter = new SimpleDateFormat(format);
   long timeStamp = Long.parseLong(timeStampStr);
   Calendar calendar = Calendar.getInstance();
   calendar.setTimeInMillis(timeStamp);
   return formatter.format(calendar.getTime());
 }
Exemplo n.º 2
1
  void dateTest() throws RuntimeException {
    Locale locTH = new Locale("th", "TH", "TH");
    TimeZone tz = TimeZone.getTimeZone("PST");

    Calendar calGregorian = Calendar.getInstance(tz, Locale.US);
    calGregorian.clear();
    calGregorian.set(2002, 4, 1, 8, 30);
    final Date date = calGregorian.getTime();
    Calendar cal = Calendar.getInstance(tz, locTH);
    cal.clear();
    cal.setTime(date);

    final String strExpected =
        "\u0E27\u0E31\u0E19\u0E1E\u0E38\u0E18\u0E17\u0E35\u0E48\u0020\u0E51\u0020\u0E1E\u0E24\u0E29\u0E20\u0E32\u0E04\u0E21\u0020\u0E1E\u002E\u0E28\u002E\u0020\u0E52\u0E55\u0E54\u0E55\u002C\u0020\u0E58\u0020\u0E19\u0E32\u0E2C\u0E34\u0E01\u0E32\u0020\u0E53\u0E50\u0020\u0E19\u0E32\u0E17\u0E35\u0020\u0E50\u0E50\u0020\u0E27\u0E34\u0E19\u0E32\u0E17\u0E35";
    Date value = cal.getTime();

    // th_TH_TH test
    DateFormat df = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL, locTH);
    df.setTimeZone(tz);
    String str = df.format(value);

    if (!strExpected.equals(str)) {
      throw new RuntimeException();
    }
  }
 private void doTest(String candidate, int expectedHours, int expectedMins) throws ParseException {
   DateFormat df = new SimpleDateFormat("HH:mm");
   Date result = df.parse(candidate);
   Calendar cal = Calendar.getInstance();
   cal.setTime(result);
   assertEquals(expectedHours, cal.get(Calendar.HOUR_OF_DAY));
   assertEquals(expectedMins, cal.get(Calendar.MINUTE));
 }
 public ArtifactView(DataProvider provider) {
   this(
       new Artifact(
           new DateTime(
               Calendar.getInstance().getTime(), DateFormat.getDateInstance(DateFormat.MEDIUM)),
           new DateTime(
               Calendar.getInstance().getTime(), DateFormat.getDateInstance(DateFormat.MEDIUM)),
           "",
           "",
           "",
           "",
           ""),
       provider);
 }
Exemplo n.º 5
0
  public void testCDate() throws ParseException {
    Date date = new Date();
    assertEquals(date, Vba.cDate(date));
    assertNull(Vba.cDate(null));
    // CInt rounds to the nearest even number
    try {
      assertEquals(DateFormat.getDateInstance().parse("Jan 12, 1952"), Vba.cDate("Jan 12, 1952"));
      assertEquals(
          DateFormat.getDateInstance().parse("October 19, 1962"), Vba.cDate("October 19, 1962"));
      assertEquals(DateFormat.getTimeInstance().parse("4:35:47 PM"), Vba.cDate("4:35:47 PM"));
      assertEquals(
          DateFormat.getDateTimeInstance().parse("October 19, 1962 4:35:47 PM"),
          Vba.cDate("October 19, 1962 4:35:47 PM"));
    } catch (ParseException e) {
      e.printStackTrace();
      fail();
    }

    try {
      Vba.cDate("Jan, 1952");
      fail();
    } catch (InvalidArgumentException e) {
      assertTrue(e.getMessage().indexOf("Jan, 1952") >= 0);
    }
  }
Exemplo n.º 6
0
 /**
  * 格式化Long类型时间
  *
  * @param longDate Long类型时间
  * @param format 时间格式
  * @return java.util.Date
  * @throws ParseException
  */
 public static Date getFormatDate(long longDate, String format) throws ParseException {
   DateFormat dformat = new SimpleDateFormat(format);
   Calendar c = Calendar.getInstance();
   c.setTimeInMillis(longDate);
   String dt = dformat.format(c.getTime());
   return dformat.parse(dt);
 }
  public String editar_Servicio() throws ParseException {

    ahora = new Date();

    servicio.setNombre(servicio.getNombre().toString().toUpperCase());
    servicio.setArquitectura(servicio.getArquitectura().toString().toUpperCase());
    servicio.setDescripcion(servicio.getDescripcion().toString().toUpperCase());
    servicio.setEstatus(servicio.getEstatus().toString().toUpperCase());
    servicio.setNivel_de_acceso(servicio.getNivel_de_acceso().toString().toUpperCase());

    @SuppressWarnings("rawtypes")
    Map session = ActionContext.getContext().getSession();
    Object fecha = session.get("fecha");

    DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss.S");

    servicio.setModificado(ahora);

    ahora = (Date) formatter.parse(fecha.toString());

    servicio.setCreado(ahora);

    editar.updateService(servicio);
    return "SUCCESS";
  }
Exemplo n.º 8
0
  public static void main(String[] args) {
    // Creates a GregorianCalendar object for the quizDay, outputs
    // information about the day, and modifies the day using class
    // methods
    // Creates the quizday object to store the day of the quiz

    GregorianCalendar quizDay = new GregorianCalendar(2014, Calendar.OCTOBER, 10);

    int month, day; // store date attributes
    // Get integer value for the characteristics
    day = quizDay.get(Calendar.DAY_OF_MONTH);
    System.out.println("Day: " + day);
    month = quizDay.get(Calendar.MONTH);
    System.out.println("Month: " + month);

    // Make the quiz 4 days earlier
    // Get the new date
    quizDay.add(Calendar.DAY_OF_MONTH, -4);
    day = quizDay.get(Calendar.DAY_OF_MONTH);
    System.out.println("Day of the quiz: " + day);
    month = quizDay.get(Calendar.MONTH);
    System.out.println("Month of the quiz: " + month);

    // Format the output of the date using DateFormat
    DateFormat fmt = DateFormat.getInstance();
    System.out.println("Formatted Date: " + fmt.format(quizDay.getTime()));
  }
    private Object getValueWithoutWebEditorsFormat(int row, int column) {
      Object r = original.getValueAt(row, column);

      if (r instanceof Boolean) {
        if (((Boolean) r).booleanValue()) return XavaResources.getString(locale, "yes");
        return XavaResources.getString(locale, "no");
      }
      if (withValidValues) {
        MetaProperty p = getMetaProperty(column);
        if (p.hasValidValues()) {
          return p.getValidValueLabel(locale, original.getValueAt(row, column));
        }
      }

      if (r instanceof java.util.Date) {
        MetaProperty p =
            getMetaProperty(column); // In order to use the type declared by the developer
        // and not the one returned by JDBC or the JPA engine
        if (java.sql.Time.class.isAssignableFrom(p.getType())) {
          return DateFormat.getTimeInstance(DateFormat.SHORT, locale).format(r);
        }
        if (java.sql.Timestamp.class.isAssignableFrom(p.getType())) {
          DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
          return dateFormat.format(r);
        }
        return DateFormat.getDateInstance(DateFormat.SHORT, locale).format(r);
      }

      if (r instanceof BigDecimal) {
        return formatBigDecimal(r, locale);
      }

      return r;
    }
Exemplo n.º 10
0
  /**
   * Leave only the value for RCS keywords.
   *
   * <p>For example, <code>$Revision: 1.1 $</code> becomes <code>1.0</code>.
   */
  public String replaceRcsKeywords(String text) {
    if (matcher == null) {
      matcher =
          Pattern.compile(
                  "\\$(Author|Date|Header|Id|Locker|Log|Name|RCSFile|Revision|Source|State): (.+?) \\$")
              .matcher(text);
    } else {
      matcher.reset(text);
    }

    StringBuffer buffer = new StringBuffer();
    while (matcher.find()) {
      String string = matcher.group(2);

      // For the Date: keyword, have a shot at reformatting string
      if ("Date".equals(matcher.group(1))) {
        try {
          DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
          Date date = dateFormat.parse(string);
          string = date.toString();
        } catch (ParseException e) {
        } // if we can't parse, return unchanged
      }

      matcher.appendReplacement(buffer, string);
    }
    matcher.appendTail(buffer);
    return buffer.toString();
  }
Exemplo n.º 11
0
 /**
  * 得到Long型时间从给定yyyy-MM-dd HH:mm:ss型字符串
  *
  * @param strDate
  * @return Long型时间
  * @throws ParseException
  */
 public static long getLongDate(String strDate) throws ParseException {
   DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
   Date date = format.parse(strDate);
   Calendar c = Calendar.getInstance();
   c.setTime(date);
   Long l = c.getTimeInMillis();
   return l;
 }
Exemplo n.º 12
0
 @Override
 public String toString(long timestamp, String timezone) {
   // Por enquanto, o fuso horário deve ser UTC:
   assert timezone.equals("UTC");
   DateFormat formatter = new SimpleDateFormat(DEFAULT_FORMAT);
   formatter.setTimeZone(TimeZone.getTimeZone(timezone));
   return formatter.format(new Date(timestamp * 1000)) + " " + timezone;
 }
Exemplo n.º 13
0
  public static void main(String[] args) {

    DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
    Date date = new Date();
    System.out.println(dateFormat.format(date));

    System.out.println("Current Time:");
  }
Exemplo n.º 14
0
 public static Range makeDate(double low, double high, boolean nameAtMid, DateFormat df) {
   Date lowDate = Data.asDate(low);
   Date highDate = Data.asDate(high);
   Date midDate = Data.asDate((high + low) / 2);
   String name =
       nameAtMid ? df.format(midDate) : df.format(lowDate) + "\u2026" + df.format(highDate);
   return new Range(lowDate, highDate, midDate, name);
 }
Exemplo n.º 15
0
 /**
  * Create a default filename given the current date selection. If custom dates are selected, use
  * those dates; otherwise, use year and week numbers.
  *
  * @return The default filename.
  */
 private String getDefaultFilename() {
   if (yearCB.getSelectedIndex() == 0 || weekCB.getSelectedIndex() == 0)
     return "timesheet-"
         + dateFormat.format(fromDate.getDate()).replaceAll("/", "")
         + "-"
         + dateFormat.format(toDate.getDate()).replaceAll("/", "")
         + ".txt";
   return "timesheet-" + yearCB.getSelectedItem() + "wk" + weekCB.getSelectedItem() + ".txt";
 }
Exemplo n.º 16
0
 /**
  * @bug 4139940 Couldn't reproduce this bug -- probably was fixed earlier.
  *     <p>ORIGINAL BUG REPORT: -- basically, hungarian for monday shouldn't have an \u00f4 (o
  *     circumflex)in it instead it should be an o with 2 inclined (right) lines over it..
  *     <p>You may wonder -- why do all this -- why not just add a line to LocaleData? Well, I
  *     could see by inspection that the locale file had the right character in it, so I wanted to
  *     check the rest of the pipeline -- a very remote possibility, but I wanted to be sure. The
  *     other possibility is that something is wrong with the font mapping subsystem, but we can't
  *     test that here.
  */
 public void Test4139940() {
   Locale mylocale = new Locale("hu", "", "");
   Date mydate = new Date(98, 3, 13); // A Monday
   DateFormat df_full = new SimpleDateFormat("EEEE", mylocale);
   String str = df_full.format(mydate);
   // Make sure that o circumflex (\u00F4) is NOT there, and
   // o double acute (\u0151) IS.
   if (str.indexOf('\u0151') < 0 || str.indexOf('\u00F4') >= 0)
     errln("Fail: Monday in Hungarian is wrong");
 }
Exemplo n.º 17
0
  protected void doGet(HttpServletRequest req, HttpServletResponse res)
      throws ServletException, IOException {
    try {
      DateFormat df = DateFormat.getDateTimeInstance();
      String titleStr = "C3P0 Status - " + df.format(new Date());

      DocumentBuilderFactory fact = DocumentBuilderFactory.newInstance();
      DocumentBuilder db = fact.newDocumentBuilder();
      Document doc = db.newDocument();

      Element htmlElem = doc.createElement("html");
      Element headElem = doc.createElement("head");

      Element titleElem = doc.createElement("title");
      titleElem.appendChild(doc.createTextNode(titleStr));

      Element bodyElem = doc.createElement("body");

      Element h1Elem = doc.createElement("h1");
      h1Elem.appendChild(doc.createTextNode(titleStr));

      Element h3Elem = doc.createElement("h3");
      h3Elem.appendChild(doc.createTextNode("PooledDataSources"));

      Element pdsDlElem = doc.createElement("dl");
      pdsDlElem.setAttribute("class", "PooledDataSources");
      for (Iterator ii = C3P0Registry.getPooledDataSources().iterator(); ii.hasNext(); ) {
        PooledDataSource pds = (PooledDataSource) ii.next();
        StatusReporter sr = findStatusReporter(pds, doc);
        pdsDlElem.appendChild(sr.reportDtElem());
        pdsDlElem.appendChild(sr.reportDdElem());
      }

      headElem.appendChild(titleElem);
      htmlElem.appendChild(headElem);

      bodyElem.appendChild(h1Elem);
      bodyElem.appendChild(h3Elem);
      bodyElem.appendChild(pdsDlElem);
      htmlElem.appendChild(bodyElem);

      res.setContentType("application/xhtml+xml");

      TransformerFactory tf = TransformerFactory.newInstance();
      Transformer transformer = tf.newTransformer();
      Source src = new DOMSource(doc);
      Result result = new StreamResult(res.getOutputStream());
      transformer.transform(src, result);
    } catch (IOException e) {
      throw e;
    } catch (Exception e) {
      throw new ServletException(e);
    }
  }
Exemplo n.º 18
0
 @Override
 public long fromString(String timestamp, String format) {
   DateFormat formatter = new SimpleDateFormat(format);
   try {
     Date date = formatter.parse(timestamp);
     return date.getTime() / 1000;
   } catch (ParseException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
   return 0L;
 }
Exemplo n.º 19
0
  /** {@inheritDoc} */
  protected String paramString() {
    String curDate;
    if ((selectedComponents & DISPLAY_DATE) == DISPLAY_DATE) {
      curDate = DateFormat.getDateInstance(DateFormat.FULL, locale).format(getDate());
    } else if ((selectedComponents & DISPLAY_TIME) == DISPLAY_TIME) {
      curDate = DateFormat.getTimeInstance(DateFormat.FULL, locale).format(getDate());
    } else {
      curDate =
          DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL, locale)
              .format(getDate());
    }

    return super.paramString() + ",selectedDate=" + curDate;
  }
Exemplo n.º 20
0
 // 将从SQL数据库中选择出来的日期性字段格式化为本地日期描述
 public String FormatDate(String DateStr) {
   if (DateStr.equals(null) || DateStr.equals("")) {
     return "    -  -  ";
   } else {
     try {
       DateFormat df = DateFormat.getDateInstance();
       Date d = df.parse(DateStr);
       df = DateFormat.getDateInstance(DateFormat.FULL);
       return df.format(d);
     } catch (ParseException e) {
       System.err.println("bean_ElearnTools.FormatDate error: " + e.getMessage());
       return DateStr;
     }
   }
 }
Exemplo n.º 21
0
  /**
   * Construct a cookie from the URI and header fields
   *
   * @param uri URI for cookie
   * @param header Set of attributes in header
   */
  public Cookie(URI uri, String header) {
    String[] attributes = header.split(";");
    String nameValue = attributes[0].trim();
    this.uri = uri;
    this.name = nameValue.substring(0, nameValue.indexOf('='));
    this.value = nameValue.substring(nameValue.indexOf('=') + 1);
    this.path = "/";
    this.domain = uri.getHost();

    for (int i = 1; i < attributes.length; i++) {
      nameValue = attributes[i].trim();
      int equals = nameValue.indexOf('=');
      if (equals == -1) {
        continue;
      }
      String name = nameValue.substring(0, equals);
      String value = nameValue.substring(equals + 1);
      if (name.equalsIgnoreCase("domain")) {
        String uriDomain = uri.getHost();
        if (uriDomain.equals(value)) {
          this.domain = value;
        } else {
          if (!value.startsWith(".")) {
            value = '.' + value;
          }
          uriDomain = uriDomain.substring(uriDomain.indexOf('.'));
          if (!uriDomain.equals(value)
              && !uriDomain.endsWith(value)
              && !value.endsWith(uriDomain)) {
            throw new IllegalArgumentException("Trying to set foreign cookie");
          }
          this.domain = value;
        }
      } else if (name.equalsIgnoreCase("path")) {
        this.path = value;
      } else if (name.equalsIgnoreCase("expires")) {
        try {
          this.expires = whiteSpaceFormat.parse(value);
        } catch (ParseException e) {
          try {
            this.expires = hyphenFormat.parse(value);
          } catch (ParseException e2) {
            throw new IllegalArgumentException("Bad date format in header: " + value);
          }
        }
      }
    }
  }
Exemplo n.º 22
0
  public TextFile openDBforFile(String dbName, String fileName, String tablePrefix) {
    perFile = new perFileStruc();

    cliDB = new sqlSolver();
    initialScript(dbName, tablePrefix);

    if (checkMisprog(cliDB == null, "cliDB")) return null;
    if (checkMisprog(cached == null, "cached")) return null;

    cliDB.openScript();
    out(
        "INSERT INTO "
            + cached.tabPrefix
            + "_files VALUES ("
            + cached.fileID
            + ", '"
            + cliDB.escapeString(DateFormat.getTodayStr())
            + "', '"
            + fileName
            + "');");

    log.dbg(2, "processOneFile", "start parsing [" + fileName + "]");
    TextFile tf = new TextFile();
    if (!tf.fopen(fileName, "rb")) // mode "rb" to be able to get the InputStream!
    {
      log.err("processOneFile", "file to parse [" + fileName + "] cannot be openned!");
      return null;
    }
    return tf;
  }
Exemplo n.º 23
0
  @Override
  public synchronized String format(LogRecord record) {
    StringBuilder sb = new StringBuilder();

    sb.append(dateFormat.format(new Date(record.getMillis())));
    sb.append(' ');
    sb.append(record.getLevel().getLocalizedName());
    sb.append(": ");
    sb.append(formatMessage(record));
    sb.append(LINE_SEPARATOR);

    if (record.getThrown() != null) {
      try {
        StringWriter sw = new StringWriter();
        PrintWriter pw = new PrintWriter(sw);
        record.getThrown().printStackTrace(pw);
        pw.close();
        sb.append(sw.toString());
      } catch (Exception e) {
        // ignore
      }
    }

    return sb.toString();
  }
Exemplo n.º 24
0
 private void commandMainPlayer(final CommandSender sender, final String[] args)
     throws CrazyCommandException {
   Player target = null;
   switch (args.length) {
     case 0:
       if (sender instanceof ConsoleCommandSender)
         throw new CrazyCommandUsageException("/crazylogin player <Player>");
       target = (Player) sender;
       break;
     case 1:
       target = getServer().getPlayer(args[0]);
       if (target == null) throw new CrazyCommandNoSuchException("Player", args[0]);
       break;
     default:
       throw new CrazyCommandUsageException("/crazylogin player [Player]");
   }
   if (sender == target)
     if (!sender.hasPermission("crazylogin.playerinfo.self"))
       throw new CrazyCommandPermissionException();
     else if (!sender.hasPermission("crazylogin.playerinfo.other"))
       throw new CrazyCommandPermissionException();
   sendLocaleMessage("PLAYERINFO.HEAD", sender, DateFormat.format(new Date()));
   sendLocaleMessage("PLAYERINFO.USERNAME", sender, target.getName());
   sendLocaleMessage("PLAYERINFO.DISPLAYNAME", sender, target.getDisplayName());
   sendLocaleMessage(
       "PLAYERINFO.IPADDRESS", sender, target.getAddress().getAddress().getHostName());
   sendLocaleMessage("PLAYERINFO.CONNECTION", sender, target.getAddress().getHostName());
   if (sender.hasPermission("crazylogin.playerinfo.extended"))
     sendLocaleMessage("PLAYERINFO.URL", sender, target.getAddress().getAddress().getHostName());
 }
Exemplo n.º 25
0
  /**
   * Create an instance of JCalendar using the given calendar and locale. Display a calendar and/or
   * a time spinner as requested (to display both use DISPLAY_DATE | DISPLAY_TIME). Display today's
   * date if requested. Set the pattern used to display the time in the time spinner field (if there
   * is one). If null, use the default MEDIUM format for the given locale. Patterns are from
   * DateFormat and SimpleDateFormat.
   *
   * @param calendar The calendar to use.
   * @param locale The locale to use.
   * @param selectedComponents Use DISPLAY_DATE, DISPLAY_TIME or (DISPLAY_DATE | DISPLAY_TIME).
   * @param isTodayDisplayed True if today's date should be displayed at the bottom of the panel.
   * @param timePattern The pattern used to display the time in the time spinner field.
   * @see DateFormat
   * @see SimpleDateFormat
   */
  public JCalendar(
      Calendar calendar,
      Locale locale,
      int selectedComponents,
      boolean isTodayDisplayed,
      String timePattern) {
    this.selectedCalendar = (Calendar) calendar.clone();
    this.displayCalendar = (Calendar) selectedCalendar.clone();
    this.selectedComponents = selectedComponents;
    if ((selectedComponents & (DISPLAY_DATE | DISPLAY_TIME)) == 0) {
      throw new IllegalStateException(bundle.getString("IllegalStateException"));
    }

    this.locale = locale;
    this.isTodayDisplayed = isTodayDisplayed;

    if ((selectedComponents & DISPLAY_TIME) > 0) {
      if (timePattern == null) {
        DateFormat timeFormat = DateFormat.getTimeInstance(DateFormat.MEDIUM, locale);
        this.timePattern = "HH:mm:ss";
        if (timeFormat instanceof SimpleDateFormat) {
          this.timePattern = ((SimpleDateFormat) timeFormat).toPattern();
        }
      } else {
        this.timePattern = timePattern;
      }
    }

    createCalendarComponents();
    setDate(new Date());
  }
Exemplo n.º 26
0
 private static String generateSimulationResultsLabel(
     String pModelName, String pSimulatorAlias, Date pResultsDateTime) {
   DateFormat df = DateFormat.getTimeInstance(DateFormat.SHORT, Locale.FRANCE);
   String timeString = df.format(pResultsDateTime);
   df = DateFormat.getDateInstance(DateFormat.SHORT);
   String dateString = df.format(pResultsDateTime);
   String abbrevModelName = pModelName;
   if (pModelName.length() > LENGTH_ABBREV_MODEL_NAME) {
     abbrevModelName = abbrevModelName.substring(0, LENGTH_ABBREV_MODEL_NAME - 1);
   }
   StringBuffer retStr = new StringBuffer();
   retStr.append("[" + dateString + " " + timeString + "] ");
   retStr.append("[" + abbrevModelName + "] ");
   retStr.append("[" + pSimulatorAlias + "]");
   return (retStr.toString());
 }
Exemplo n.º 27
0
  /** Write [DATE] Buy [SYMBOL] [NUMBER]sh @[PRICE] = [VALUE] --> [NUMBER]sh held * */
  public void orderBought(
      TradeOrder order, Date date, StockPosition position, TradingAccount account) {
    double profitOrLoss =
        (order.shares * (order.getExecutedPrice() - position.getCostBasis())
            - account.getTradeFees(order.shares));

    double percent = profitOrLoss / (position.getCostBasis() * order.shares);

    this.writer.println(
        DATE_FORMAT.format(date)
            + " "
            + (position.getShares() != 0 ? "Buy " : "Cover ")
            + order.symbol
            + " "
            + order.shares
            + "sh "
            + "@"
            + DOLLAR_FORMAT.format(order.getExecutedPrice())
            + " = "
            + DOLLAR_FORMAT.format(order.getExecutedValue())
            + " --> "
            + position.getShares()
            + "sh "
            + (position.getShares() <= 0
                ? "left, "
                    + DOLLAR_FORMAT.format(profitOrLoss)
                    + (profitOrLoss > 0
                        ? " (" + PERCENT_FORMAT.format(percent) + " profit)"
                        : profitOrLoss < 0
                            ? " (" + PERCENT_FORMAT.format(percent) + "loss)"
                            : " (even)")
                : "long"));

    this.lastTraceDate = date;
  }
 private void startTag(String aPrefix, String aName, XmlPullParser aParser) throws Exception {
   if ("entry".equals(aName)) {
     tweets.addTweet(currentTweet = new Tweet());
   } else if ("published".equals(aName)) {
     aParser.next();
     currentTweet.setPublished(dateFormat.parse(aParser.getText()));
   } else if (("title".equals(aName)) && (currentTweet != null)) {
     aParser.next();
     currentTweet.setTitle(aParser.getText());
   } else if ("content".equals(aName)) {
     Content _c = new Content();
     _c.setType(aParser.getAttributeValue(null, "type"));
     aParser.next();
     _c.setValue(aParser.getText());
     currentTweet.setContent(_c);
   } else if ("lang".equals(aName)) {
     aParser.next();
     currentTweet.setLanguage(aParser.getText());
   } else if ("author".equals(aName)) {
     currentTweet.setAuthor(currentAuthor = new Author());
   } else if ("name".equals(aName)) {
     aParser.next();
     currentAuthor.setName(aParser.getText());
   } else if ("uri".equals(aName)) {
     aParser.next();
     currentAuthor.setUri(aParser.getText());
   }
 }
Exemplo n.º 29
0
  ///////////////////////////////////
  // constructor
  //////////////////////////////////
  public SwingImportRangeData(
      final Layers theData, final String lastDirectory, final PropertiesPanel thePanel) {
    super(theData, lastDirectory, thePanel);

    // initialise the date to GMT, so that the date points aren't shifted
    _dateF.setTimeZone(java.util.TimeZone.getTimeZone("GMT"));
  }
Exemplo n.º 30
0
 /** Write initial cash balance. * */
 public void initialized(Date date, TradingAccount account) {
   writer.println(
       DATE_FORMAT.format(date)
           + ": "
           + "cash="
           + DOLLAR_FORMAT.format(account.getCurrentCashBalance()));
   this.lastTraceDate = date;
 }