List of usage examples for java.text DateFormat getDateTimeInstance
public static final DateFormat getDateTimeInstance()
From source file:com.QuarkLabs.BTCeClientJavaFX.MainController.java
@FXML void initialize() { assert clearLogButton != null : "fx:id=\"clearLogButton\" was not injected: check your FXML file 'mainlayout.fxml'."; assert fundsTable != null : "fx:id=\"fundsTable\" was not injected: check your FXML file 'mainlayout.fxml'."; assert logField != null : "fx:id=\"logField\" was not injected: check your FXML file 'mainlayout.fxml'."; assert buyButton != null : "fx:id=\"buyButton\" was not injected: check your FXML file 'mainlayout.fxml'."; assert sellButton != null : "fx:id=\"sellButton\" was not injected: check your FXML file 'mainlayout.fxml'."; assert showActiveOrdersButton != null : "fx:id=\"showActiveOrdersButton\" was not injected: check your FXML file 'mainlayout.fxml'."; assert tickersTableLastColumn != null : "fx:id=\"tickerTableLastColumn\" was not injected: check your FXML file 'mainlayout.fxml'."; assert tickersTablePairColumn != null : "fx:id=\"tickerTablePairColumn\" was not injected: check your FXML file 'mainlayout.fxml'."; assert tickersTable != null : "fx:id=\"tickersTable\" was not injected: check your FXML file 'mainlayout.fxml'."; assert tickersTableBuyColumn != null : "fx:id=\"tickersTableBuyColumn\" was not injected: check your FXML file 'mainlayout.fxml'."; assert tickersTableFeeColumn != null : "fx:id=\"tickersTableFeeColumn\" was not injected: check your FXML file 'mainlayout.fxml'."; assert tickersTableSellColumn != null : "fx:id=\"tickersTableSellColumn\" was not injected: check your FXML file 'mainlayout.fxml'."; assert tradeAmountValue != null : "fx:id=\"tradeAmountValue\" was not injected: check your FXML file 'mainlayout.fxml'."; assert tradePriceCurrencyType != null : "fx:id=\"tradeCurrencyPriceValue\" was not injected: check your FXML file 'mainlayout.fxml'."; assert tradeCurrencyType != null : "fx:id=\"tradeCurrencyType\" was not injected: check your FXML file 'mainlayout.fxml'."; assert tradePriceValue != null : "fx:id=\"tradePriceValue\" was not injected: check your FXML file 'mainlayout.fxml'."; assert updateFundsButton != null : "fx:id=\"updateFundsButton\" was not injected: check your FXML file 'mainlayout.fxml'."; assert fundsTableCurrencyColumn != null : "fx:id=\"fundsTableCurrencyColumn\" was not injected: check your FXML file 'mainlayout.fxml'."; assert fundsTableValueColumn != null : "fx:id=\"fundsTableValueColumn\" was not injected: check your FXML file 'mainlayout.fxml'."; assert activeOrdersTable != null : "fx:id=\"fundsTableValueColumn\" was not injected: check your FXML file 'mainlayout.fxml'."; assert activeOrdersAmountColumn != null : "fx:id=\"activeOrdersAmountColumn\" was not injected: check your FXML file 'mainlayout.fxml'."; assert activeOrdersPairColumn != null : "fx:id=\"activeOrdersPairColumn\" was not injected: check your FXML file 'mainlayout.fxml'."; assert activeOrdersRateColumn != null : "fx:id=\"activeOrdersRateColumn\" was not injected: check your FXML file 'mainlayout.fxml'."; assert activeOrdersTimeColumn != null : "fx:id=\"activeOrdersTimeColumn\" was not injected: check your FXML file 'mainlayout.fxml'."; assert activeOrdersTypeColumn != null : "fx:id=\"activeOrdersTypeColumn\" was not injected: check your FXML file 'mainlayout.fxml'."; assert activeOrdersCancelColumn != null : "fx:id=\"activeOrdersCancelColumn\" was not injected: check your FXML file 'mainlayout.fxml'."; //Holder for all main API methods of exchange app = new App(); //Loading configs loadExchangeConfig();// w w w.j a v a2 s . co m //Populate choiceboxes at the trading section tradeCurrencyType.setItems(FXCollections.observableArrayList(currencies)); tradeCurrencyType.setValue(currencies.get(0)); tradePriceCurrencyType.setItems(FXCollections.observableArrayList(currencies)); tradePriceCurrencyType.setValue(currencies.get(0)); //Active Orders table activeOrdersAmountColumn.setCellValueFactory(new PropertyValueFactory<ActiveOrder, Double>("amount")); activeOrdersPairColumn.setCellValueFactory(new PropertyValueFactory<ActiveOrder, String>("pair")); activeOrdersRateColumn.setCellValueFactory(new PropertyValueFactory<ActiveOrder, Double>("rate")); activeOrdersTimeColumn.setCellValueFactory( new Callback<TableColumn.CellDataFeatures<ActiveOrder, String>, ObservableValue<String>>() { @Override public ObservableValue<String> call( TableColumn.CellDataFeatures<ActiveOrder, String> activeOrderStringCellDataFeatures) { ActiveOrder activeOrder = activeOrderStringCellDataFeatures.getValue(); DateFormat dateFormat = DateFormat.getDateTimeInstance(); Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(activeOrder.getTimestamp() * 1000); return new SimpleStringProperty(dateFormat.format(calendar.getTime())); } }); activeOrdersTypeColumn.setCellValueFactory(new PropertyValueFactory<ActiveOrder, String>("type")); activeOrdersTable.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY); activeOrdersCancelColumn .setCellFactory(new Callback<TableColumn<ActiveOrder, Boolean>, TableCell<ActiveOrder, Boolean>>() { @Override public TableCell<ActiveOrder, Boolean> call( TableColumn<ActiveOrder, Boolean> activeOrderBooleanTableColumn) { return new ButtonCell<>(activeOrdersTable); } }); activeOrdersCancelColumn.setCellValueFactory( new Callback<TableColumn.CellDataFeatures<ActiveOrder, Boolean>, ObservableValue<Boolean>>() { @Override public ObservableValue<Boolean> call( TableColumn.CellDataFeatures<ActiveOrder, Boolean> activeOrderBooleanCellDataFeatures) { return new SimpleBooleanProperty(true); } }); //Tickers Table MenuItem showOrdersBook = new MenuItem("Show Orders Book"); MenuItem showPublicTrades = new MenuItem("Show Public Trades"); ContextMenu contextMenu = new ContextMenu(showOrdersBook, showPublicTrades); tickersTable.setItems(tickers); tickersTable.setContextMenu(contextMenu); tickersTableBuyColumn.setCellValueFactory(new PropertyValueFactory<Ticker, Double>("buy")); tickersTableFeeColumn.setCellValueFactory(new PropertyValueFactory<Ticker, Double>("fee")); tickersTableSellColumn.setCellValueFactory(new PropertyValueFactory<Ticker, Double>("sell")); tickersTableLastColumn.setCellValueFactory(new PropertyValueFactory<Ticker, Double>("last")); tickersTablePairColumn.setCellValueFactory(new PropertyValueFactory<Ticker, String>("pair")); tickersTable.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY); tickersTable.setRowFactory(new Callback<TableView<Ticker>, TableRow<Ticker>>() { @Override public TableRow<Ticker> call(TableView<Ticker> tickerTableView) { return new TableRow<Ticker>() { @Override protected void updateItem(Ticker ticker, boolean b) { super.updateItem(ticker, b); if (!b) { if (tickersData.containsKey(ticker.getPair())) { if (ticker.getLast() < tickersData.get(ticker.getPair()).getLast()) { setStyle("-fx-control-inner-background: rgba(186, 0, 0, 0.5);"); } else if (ticker.getLast() == tickersData.get(ticker.getPair()).getLast()) { setStyle("-fx-control-inner-background: rgba(215, 193, 44, 0.5);"); } else { setStyle("-fx-control-inner-background: rgba(0, 147, 0, 0.5);"); } } } } }; } }); //Menu item to show Orders Book showOrdersBook.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent actionEvent) { Ticker selectedTicker = tickersTable.getSelectionModel().getSelectedItem(); Parent root; try { FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource(PATH_TO_ORDERS_BOOK_LAYOUT), resources); root = (Parent) fxmlLoader.load(); OrdersBookController ordersBookController = fxmlLoader.getController(); ordersBookController.injectPair(selectedTicker.getPair()); Stage stage = new Stage(); stage.setTitle("Orders Book for " + selectedTicker.getPair().replace("_", "/").toUpperCase()); stage.setScene(new Scene(root)); stage.setResizable(false); stage.show(); } catch (IOException e) { e.printStackTrace(); } } }); //Menu item to show Public Trades showPublicTrades.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent actionEvent) { Ticker selectedTicker = tickersTable.getSelectionModel().getSelectedItem(); Parent root; try { FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource(PATH_TO_TRADES_LAYOUT), resources); root = (Parent) fxmlLoader.load(); PublicTradesController publicTradesController = fxmlLoader.getController(); publicTradesController.injectPair(selectedTicker.getPair()); Stage stage = new Stage(); stage.setTitle("Public Trades for " + selectedTicker.getPair().replace("_", "/").toUpperCase()); stage.setScene(new Scene(root)); stage.setResizable(false); stage.show(); } catch (IOException e) { e.printStackTrace(); } } }); //Funds Table fundsTableCurrencyColumn.setCellValueFactory(new PropertyValueFactory<Fund, String>("currency")); fundsTableValueColumn.setCellValueFactory(new PropertyValueFactory<Fund, Double>("value")); fundsTable.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY); fundsTable.setItems(fundsData); //Task to load tickers data from server final javafx.concurrent.Service loadTickersService = new javafx.concurrent.Service() { @Override protected Task createTask() { Task<JSONObject> loadTickers = new Task<JSONObject>() { @Override protected JSONObject call() throws Exception { String[] pairsArray = new String[pairs.size()]; pairsArray = pairs.toArray(pairsArray); return App.getPairInfo(pairsArray); } }; loadTickers.setOnFailed(new EventHandler<WorkerStateEvent>() { @Override public void handle(WorkerStateEvent workerStateEvent) { logField.appendText(workerStateEvent.getSource().getException().getMessage() + "\r\n"); } }); loadTickers.setOnSucceeded(new EventHandler<WorkerStateEvent>() { @Override public void handle(WorkerStateEvent workerStateEvent) { JSONObject jsonObject = (JSONObject) workerStateEvent.getSource().getValue(); //ugly hack to store old values //dump old values to tickersData //TODO think about better solution if (tickers.size() != 0) { for (Ticker x : tickers) { tickersData.put(x.getPair(), x); } } tickers.clear(); for (Iterator iterator = jsonObject.keys(); iterator.hasNext();) { String key = (String) iterator.next(); JSONObject data = jsonObject.getJSONObject(key); Ticker ticker = new Ticker(); ticker.setPair(key); ticker.setUpdated(data.optLong("updated")); ticker.setAvg(data.optDouble("avg")); ticker.setBuy(data.optDouble("buy")); ticker.setSell(data.optDouble("sell")); ticker.setHigh(data.optDouble("high")); ticker.setLast(data.optDouble("last")); ticker.setLow(data.optDouble("low")); ticker.setVol(data.optDouble("vol")); ticker.setVolCur(data.optDouble("vol_cur")); tickers.add(ticker); } } }); return loadTickers; } }; //Update tickers every 15 seconds //TODO better solution is required Timeline timeline = new Timeline(new KeyFrame(Duration.ZERO, new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent actionEvent) { loadTickersService.restart(); } }), new KeyFrame(Duration.seconds(15))); timeline.setCycleCount(Timeline.INDEFINITE); timeline.playFromStart(); }
From source file:com.xpfriend.fixture.cast.temp.ObjectValidatorBase.java
private Object toDate(String actual) { Date date;/*from w w w .ja v a 2s.c o m*/ if ((date = parse(DateFormat.getDateInstance(), actual)) != null) { return date; } if ((date = parse(DateFormat.getDateTimeInstance(), actual)) != null) { return date; } TimeZone timeZone = TimeZone.getDefault(); for (int i = 0; i < DATEFORMATS.length; i++) { DateFormat dateFormat = dateFormatter.getDateFormat(DATEFORMATS[i], timeZone); if ((date = parse(dateFormat, actual)) != null) { return date; } } return actual; }
From source file:org.openmrs.module.rheapocadapter.impl.HL7MessageTransformer.java
private Obs parseObs(OBX obx, OBR obr, PID pid, PV1 pv1) throws HL7Exception, ParseException { if (log.isDebugEnabled()) log.debug("parsing observation: " + obx); Encounter encounter = new Encounter(); if (pv1 != null) { encounter.setEncounterDatetime(//from w w w. j a v a 2s . c om DateFormat.getDateTimeInstance().parse(pv1.getAdmitDateTime().getTime().getValue())); } Varies[] values = obx.getObservationValue(); // bail out if no values were found if (values == null || values.length < 1) return null; String hl7Datatype = values[0].getName(); if (log.isDebugEnabled()) log.debug(" datatype = " + hl7Datatype); Concept concept = getConcept(obx.getObservationIdentifier()); if (log.isDebugEnabled()) log.debug(" concept = " + concept.getConceptId()); ConceptName conceptName = getConceptName(obx.getObservationIdentifier()); if (log.isDebugEnabled()) log.debug(" concept-name = " + conceptName); Date datetime = getDatetime(obx); if (log.isDebugEnabled()) log.debug(" timestamp = " + datetime); if (datetime == null) datetime = new Date(); Obs obs = new Obs(); Patient patient = getPatient(pid); obs.setPerson(patient); obs.setConcept(concept); obs.setEncounter(encounter); obs.setObsDatetime(datetime); obs.setLocation(null); obs.setCreator(Context.getAuthenticatedUser()); obs.setDateCreated(getDatetime(obr)); Type obx5 = values[0].getData(); if ("NM".equals(hl7Datatype)) { String value = ((NM) obx5).getValue(); if (value == null || value.length() == 0) { log.warn("Not creating null valued obs for concept " + concept); return null; } else if (value.equals("0") || value.equals("1")) { obs.setConcept(concept); if (concept.getDatatype().isBoolean()) { obs.setValueAsString(value.equals("1") ? "true" : "false"); } else if (concept.getDatatype().isNumeric()) try { obs.setValueNumeric(Double.valueOf(value)); } catch (NumberFormatException e) { throw new HL7Exception("numeric (NM) value '" + value + "' is not numeric for concept #" + concept.getConceptId() + " (" + conceptName.getName() + ") ", e); } else if (concept.getDatatype().isCoded()) { Concept answer = value.equals("1") ? Context.getConceptService().getConceptByName("true") : Context.getConceptService().getConceptByName("false"); boolean isValidAnswer = false; Collection<ConceptAnswer> conceptAnswers = concept.getAnswers(); if (conceptAnswers != null && conceptAnswers.size() > 0) { for (ConceptAnswer conceptAnswer : conceptAnswers) { if (conceptAnswer.getAnswerConcept().equals(answer)) { obs.setValueCoded(answer); isValidAnswer = true; break; } } } // answer the boolean answer concept was't found if (!isValidAnswer) throw new HL7Exception(answer.toString() + " is not a valid answer for obs with uuid "); } else { // throw this exception to make sure that the handler // doesn't silently ignore bad hl7 message throw new HL7Exception("Can't set boolean concept answer for concept with id " + obs.getConcept().getConceptId()); } } else { try { obs.setValueNumeric(Double.valueOf(value)); } catch (NumberFormatException e) { throw new HL7Exception("numeric (NM) value '" + value + "' is not numeric for concept #" + concept.getConceptId() + " (" + conceptName.getName() + ") in message ", e); } } } else if ("CWE".equals(hl7Datatype)) { log.debug(" CWE observation"); CWE value = (CWE) obx5; String valueIdentifier = value.getIdentifier().getValue(); log.debug(" value id = " + valueIdentifier); String valueName = value.getText().getValue(); log.debug(" value name = " + valueName); try { Concept valueConcept = getConcept(value); obs.setValueCoded(valueConcept); } catch (NumberFormatException e) { throw new HL7Exception( "Invalid concept ID '" + valueIdentifier + "' for OBX-5 value '" + valueName + "'"); } if (log.isDebugEnabled()) log.debug(" Done with CWE"); } else if ("CE".equals(hl7Datatype)) { CE value = (CE) obx5; String valueIdentifier = value.getIdentifier().getValue(); String valueName = value.getText().getValue(); try { obs.setValueCoded(getConcept(value)); } catch (NumberFormatException e) { throw new HL7Exception( "Invalid concept ID '" + valueIdentifier + "' for OBX-5 value '" + valueName + "'"); } } else if ("DT".equals(hl7Datatype)) { DT value = (DT) obx5; Date valueDate = getDate(value.getYear(), value.getMonth(), value.getDay(), 0, 0, 0); if (value == null || valueDate == null) { log.warn("Not creating null valued obs for concept " + concept); return null; } obs.setValueDatetime(valueDate); } else if ("TS".equals(hl7Datatype)) { DTM value = ((TS) obx5).getTime(); Date valueDate = getDate(value.getYear(), value.getMonth(), value.getDay(), value.getHour(), value.getMinute(), value.getSecond()); if (value == null || valueDate == null) { log.warn("Not creating null valued obs for concept " + concept); return null; } obs.setValueDatetime(valueDate); } else if ("TM".equals(hl7Datatype)) { TM value = (TM) obx5; Date valueTime = getDate(0, 0, 0, value.getHour(), value.getMinute(), value.getSecond()); if (value == null || valueTime == null) { log.warn("Not creating null valued obs for concept " + concept); return null; } obs.setValueDatetime(valueTime); } else if ("ST".equals(hl7Datatype)) { ST value = (ST) obx5; if (value == null || value.getValue() == null || value.getValue().trim().length() == 0) { log.warn("Not creating null valued obs for concept " + concept); return null; } obs.setValueText(value.getValue()); } else { // unsupported data type throw new HL7Exception("Unsupported observation datatype '" + hl7Datatype + "'"); } return obs; }
From source file:uk.bowdlerize.service.CensorCensusService.java
private void performProbe(final Intent intent) { Intent newIntent = new Intent(); newIntent.setAction(ProgressFragment.ORG_BROADCAST); newIntent.putExtra(ProgressFragment.ORG_BROADCAST, ProgressFragment.TALKING_TO_ISP); sendBroadcast(newIntent);// w w w . j a va 2 s . com //If this is user submitted send it up for further research if (intent.getBooleanExtra("local", false)) { new Thread() { public void run() { try { api.submitURL(intent.getStringExtra("url")); } catch (Exception e) { e.printStackTrace(); } } }.start(); } mBuilder.setStyle(new NotificationCompat.InboxStyle() .setBigContentTitle(getString(R.string.notifTitle) + " - " + getString(R.string.notifURLRecv)) .addLine(getString(R.string.notifNewURL)).addLine(getString(R.string.notifSanityCheck)) .setSummaryText(Integer.toString(checkedCount) + " " + getString(R.string.notifChecked) + " / " + Integer.toString(censoredCount) + " " + getString(R.string.notifPossBlock))) .setSmallIcon(R.drawable.ic_stat_in_progress) .setLargeIcon(BitmapFactory.decodeResource(mContext.getResources(), R.drawable.ic_ooni_large)) .setPriority(Notification.PRIORITY_MAX) .setTicker(getString(R.string.notifTitle) + " - " + getString(R.string.notifURLRecv)) .setAutoCancel(false); mNotifyManager.notify(NOTIFICATION_ID, mBuilder.build()); new Thread(new Runnable() { @Override public void run() { String url = intent.getStringExtra("url"); String hash = intent.getStringExtra("hash"); //Pair<Boolean,Integer> wasCensored; CensorPayload censorPayload; String currentDateTimeString = DateFormat.getDateTimeInstance().format(new Date()); mBuilder.setStyle(new NotificationCompat.InboxStyle() .setBigContentTitle( getString(R.string.notifTitle) + " - " + getString(R.string.notifCheckURL)) .addLine(getString(R.string.notifStartAt) + " " + currentDateTimeString) .addLine(getString(R.string.notifCheckURL) + ".....").addLine("MD5: " + hash) .setSummaryText(Integer.toString(checkedCount) + " " + getString(R.string.notifChecked) + " / " + Integer.toString(censoredCount) + " " + getString(R.string.notifPossBlock))); mBuilder.setProgress(2, 1, true); mNotifyManager.notify(NOTIFICATION_ID, mBuilder.build()); try { if (null == url) throw new NullPointerException(); //Do the actual check censorPayload = checkURL(url); //We're complete - update the time currentDateTimeString = DateFormat.getDateTimeInstance().format(new Date()); //Update our local stats setCounts(censorPayload.wasCensored()); censorPayload.MD5 = hash; Intent ORGCensorIntent = new Intent(); ORGCensorIntent.setAction(ProgressFragment.ORG_BROADCAST); ORGCensorIntent.putExtra("url", url); ORGCensorIntent.putExtra("hash", hash); ORGCensorIntent.putExtra("date", currentDateTimeString); if (censorPayload.wasCensored()) { ORGCensorIntent.putExtra(ProgressFragment.ORG_BROADCAST, ProgressFragment.BLOCKED); ORGCensorIntent.putExtra(ResultsGrid.INTENT_FILTER, LocalCache.RESULT_BLOCKED); mBuilder.setTicker(getString(R.string.notifFoundBlock)); mBuilder.setStyle(new NotificationCompat.InboxStyle() .setBigContentTitle( getString(R.string.notifTitle) + " - " + getString(R.string.notifWaiting)) .addLine(getString(R.string.notifLastChk) + ": " + currentDateTimeString) .addLine(getString(R.string.notifLastURLBlocked)) .addLine("MD5: " + intent.getStringExtra("hash")) .setSummaryText(Integer.toString(checkedCount) + " " + getString(R.string.notifChecked) + " / " + Integer.toString(censoredCount) + " " + getString(R.string.notifPossBlock)) ); mBuilder.setLargeIcon(BitmapFactory.decodeResource(mContext.getResources(), R.drawable.ic_ooni_large_censored)); } else { ORGCensorIntent.putExtra(ProgressFragment.ORG_BROADCAST, ProgressFragment.OK); ORGCensorIntent.putExtra(ResultsGrid.INTENT_FILTER, LocalCache.RESULT_OK); mBuilder.setTicker( getString(R.string.notifTitle) + " - " + getString(R.string.notifLastChkNotBlock)); mBuilder.setStyle(new NotificationCompat.InboxStyle() .setBigContentTitle( getString(R.string.notifTitle) + " - " + getString(R.string.notifWaiting)) .addLine(getString(R.string.notifLastChk) + ": " + currentDateTimeString) .addLine(getString(R.string.notifLastChkNotBlock)) .setSummaryText(Integer.toString(checkedCount) + " " + getString(R.string.notifChecked) + " / " + Integer.toString(censoredCount) + " " + getString(R.string.notifPossBlock))); } sendBroadcast(ORGCensorIntent); } catch (Exception e) { e.printStackTrace(); //We're complete - update the time currentDateTimeString = DateFormat.getDateTimeInstance().format(new Date()); mBuilder.setStyle(new NotificationCompat.InboxStyle() .setBigContentTitle( getString(R.string.notifTitle) + " - " + getString(R.string.notifError)) .addLine(getString(R.string.notifLastChk) + ": " + currentDateTimeString) .addLine(getString(R.string.notifException)) .setSummaryText(Integer.toString(checkedCount) + " " + getString(R.string.notifChecked) + " / " + Integer.toString(censoredCount) + " " + getString(R.string.notifPossBlock))); censorPayload = null; Intent newIntent = new Intent(); newIntent.setAction(ProgressFragment.ORG_BROADCAST); newIntent.putExtra(ProgressFragment.ORG_BROADCAST, ProgressFragment.NO_URLS); sendBroadcast(newIntent); } mBuilder.setProgress(0, 0, false); mBuilder.setSmallIcon(R.drawable.ic_stat_waiting); mNotifyManager.notify(NOTIFICATION_ID, mBuilder.build()); //Send the details back regardless (will chew DB space but will give a clearer picture) //api.notifyBackEnd(url,"",wasCensored, intent.getStringExtra("isp"), intent.getStringExtra("sim")); api.notifyBackEnd(censorPayload); /*if(sendtoORG) notifyOONIDirectly(url,wasCensored, intent.getStringExtra("isp"), intent.getStringExtra("sim")); */ onProbeFinish(); } }).start(); }
From source file:net.sourceforge.fullsync.ui.FileObjectChooser.java
private void populateList() throws FileSystemException { FileObject[] children = activeFileObject.getChildren(); Arrays.sort(children, (o1, o2) -> { try {/* w w w . ja v a 2s .co m*/ if ((o1.getType() == FileType.FOLDER) && (o2.getType() == FileType.FILE)) { return -1; } else if ((o1.getType() == FileType.FILE) && (o2.getType() == FileType.FOLDER)) { return 1; } return o1.getName().getBaseName().compareTo(o2.getName().getBaseName()); } catch (FileSystemException fse) { fse.printStackTrace(); return 0; } }); DateFormat df = DateFormat.getDateTimeInstance(); for (int i = 0; i < children.length; i++) { FileObject data = children[i]; TableItem item; if (tableItems.getItemCount() <= i) { item = new TableItem(tableItems, SWT.NULL); } else { item = tableItems.getItem(i); } item.setText(0, data.getName().getBaseName()); String type = data.getType().getName(); //FIXME: translate type name {file,folder} if (data.getType().hasContent()) { FileContent content = data.getContent(); String contentType = content.getContentInfo().getContentType(); if (null != contentType) { type += " (" + contentType + ")"; //$NON-NLS-1$ //$NON-NLS-2$ } item.setText(1, String.valueOf(content.getSize())); item.setText(3, df.format(new Date(content.getLastModifiedTime()))); } else { item.setText(1, ""); //$NON-NLS-1$ item.setText(3, ""); //$NON-NLS-1$ } item.setText(2, type); if (data.getType() == FileType.FOLDER) { item.setImage(imageRepository.getImage("FS_Folder_Collapsed.gif")); //$NON-NLS-1$ } else { item.setImage(imageRepository.getImage("FS_File_text_plain.gif")); //$NON-NLS-1$ } item.setData(data); } tableItems.setItemCount(children.length); }
From source file:com.eryansky.common.utils.DateUtil.java
/** * /* w ww. j a va 2 s. co m*/ * @date1?date2? ? 2008-08-08 16:16:34 * @param date1 * @param date2 * @return */ public static boolean isDateBefore(String date1, String date2) { try { DateFormat df = DateFormat.getDateTimeInstance(); return df.parse(date1).before(df.parse(date2)); } catch (ParseException e) { System.out.print("[SYS] " + e.getMessage()); return false; } }
From source file:Load_RSS_p.java
public static serverObjects respond(@SuppressWarnings("unused") final RequestHeader header, final serverObjects post, final serverSwitch env) { final serverObjects prop = new serverObjects(); final Switchboard sb = (Switchboard) env; final String collection = post == null ? "user" : CommonPattern.SPACE.matcher(post.get("collection", "user").trim()).replaceAll(""); Map<String, Pattern> collections = CrawlProfile.collectionParser(collection); boolean collectionEnabled = sb.index.fulltext().getDefaultConfiguration().isEmpty() || sb.index.fulltext().getDefaultConfiguration().contains(CollectionSchema.collection_sxt); prop.put("showload_collectionEnabled", collectionEnabled ? 1 : 0); prop.put("showload_collection", collection); prop.put("showload", 0); prop.put("showitems", 0); prop.put("shownewfeeds", 0); prop.put("showscheduledfeeds", 0); prop.put("url", ""); prop.put("showerrmsg", 0); if (post != null && post.containsKey("removeSelectedFeedsNewList")) { for (final Map.Entry<String, String> entry : post.entrySet()) { if (entry.getValue().startsWith(CHECKBOX_ITEM_PREFIX)) try { sb.tables.delete("rss", entry.getValue().substring(CHECKBOX_ITEM_PREFIX.length()).getBytes()); } catch (final IOException e) { ConcurrentLog.logException(e); }/*from w w w .j av a 2 s . c o m*/ } } if (post != null && post.containsKey("removeAllFeedsNewList")) try { final Iterator<Row> plainIterator = sb.tables.iterator("rss"); Row row; String messageurl; final List<byte[]> d = new ArrayList<byte[]>(); while (plainIterator.hasNext()) { row = plainIterator.next(); if (row == null) continue; messageurl = row.get("url", ""); if (messageurl.isEmpty()) continue; final byte[] api_pk = row.get("api_pk"); final Row r = api_pk == null ? null : sb.tables.select("api", api_pk); if (r == null || !r.get("comment", "").matches(".*" + Pattern.quote(messageurl) + ".*")) { d.add(row.getPK()); } } for (final byte[] pk : d) { sb.tables.delete("rss", pk); } } catch (final IOException e) { ConcurrentLog.logException(e); } catch (final SpaceExceededException e) { ConcurrentLog.logException(e); } if (post != null && post.containsKey("removeSelectedFeedsScheduler")) { for (final Map.Entry<String, String> entry : post.entrySet()) { if (entry.getValue().startsWith(CHECKBOX_ITEM_PREFIX)) try { final byte[] pk = entry.getValue().substring(CHECKBOX_ITEM_PREFIX.length()).getBytes(); final Row rssRow = sb.tables.select("rss", pk); final byte[] schedulerPK = rssRow.get("api_pk", (byte[]) null); if (schedulerPK != null) sb.tables.delete("api", schedulerPK); rssRow.remove("api_pk"); sb.tables.insert("rss", pk, rssRow); } catch (final IOException e) { ConcurrentLog.logException(e); } catch (final SpaceExceededException e) { ConcurrentLog.logException(e); } } } if (post != null && post.containsKey("removeAllFeedsScheduler")) try { final Iterator<Row> plainIterator = sb.tables.iterator("rss"); Row row; String messageurl; final List<byte[]> d = new ArrayList<byte[]>(); while (plainIterator.hasNext()) { row = plainIterator.next(); if (row == null) continue; messageurl = row.get("url", ""); if (messageurl.isEmpty()) continue; final byte[] api_pk = row.get("api_pk"); final Row r = api_pk == null ? null : sb.tables.select("api", api_pk); if (r != null && r.get("comment", "").matches(".*" + Pattern.quote(messageurl) + ".*")) { d.add(row.getPK()); } } for (final byte[] pk : d) { final Row rssRow = sb.tables.select("rss", pk); final byte[] schedulerPK = rssRow.get("api_pk", (byte[]) null); if (schedulerPK != null) sb.tables.delete("api", schedulerPK); rssRow.remove("api_pk"); sb.tables.insert("rss", pk, rssRow); } } catch (final IOException e) { ConcurrentLog.logException(e); } catch (final SpaceExceededException e) { ConcurrentLog.logException(e); } if (post != null && post.containsKey("addSelectedFeedScheduler")) { ClientIdentification.Agent agent = ClientIdentification .getAgent(post.get("agentName", ClientIdentification.yacyInternetCrawlerAgentName)); for (final Map.Entry<String, String> entry : post.entrySet()) { if (entry.getValue().startsWith(CHECKBOX_ITEM_PREFIX)) { Row row; try { final byte[] pk = entry.getValue().substring(CHECKBOX_ITEM_PREFIX.length()).getBytes(); row = sb.tables.select("rss", pk); } catch (final IOException e) { ConcurrentLog.logException(e); continue; } catch (final SpaceExceededException e) { ConcurrentLog.logException(e); continue; } DigestURL url = null; try { url = new DigestURL(row.get("url", "")); } catch (final MalformedURLException e) { ConcurrentLog.warn("Load_RSS", "malformed url '" + row.get("url", "") + "': " + e.getMessage()); continue; } // load feeds concurrently to get better responsibility in web interface new RSSLoader(sb, url, collections, agent).start(); } } } if (post == null || (post != null && (post.containsKey("addSelectedFeedScheduler") || post.containsKey("removeSelectedFeedsNewList") || post.containsKey("removeAllFeedsNewList") || post.containsKey("removeSelectedFeedsScheduler") || post.containsKey("removeAllFeedsScheduler")))) { try { // get list of primary keys from the api table with scheduled feed loading requests Tables.Row row; String messageurl; // check feeds int newc = 0, apic = 0; final Iterator<Row> plainIterator = sb.tables.iterator("rss"); while (plainIterator.hasNext()) { row = plainIterator.next(); if (row == null) continue; messageurl = row.get("url", ""); if (messageurl.isEmpty()) continue; // get referrer final DigestURL referrer = sb.getURL(row.get("referrer", "").getBytes()); // check if feed is registered in scheduler final byte[] api_pk = row.get("api_pk"); final Row r = api_pk == null ? null : sb.tables.select("api", api_pk); if (r != null && r.get("comment", "").matches(".*" + Pattern.quote(messageurl) + ".*")) { // this is a recorded entry final Date date_next_exec = r.get(WorkTables.TABLE_API_COL_DATE_NEXT_EXEC, (Date) null); prop.put("showscheduledfeeds_list_" + apic + "_pk", UTF8.String(row.getPK())); prop.put("showscheduledfeeds_list_" + apic + "_count", apic); prop.put("showscheduledfeeds_list_" + apic + "_rss", MultiProtocolURL.escape(messageurl).toString()); prop.putXML("showscheduledfeeds_list_" + apic + "_title", row.get("title", "")); prop.putXML("showscheduledfeeds_list_" + apic + "_referrer", referrer == null ? "#" : referrer.toNormalform(true)); prop.put("showscheduledfeeds_list_" + apic + "_recording", DateFormat.getDateTimeInstance().format(row.get("recording_date", new Date()))); prop.put("showscheduledfeeds_list_" + apic + "_lastload", DateFormat.getDateTimeInstance().format(row.get("last_load_date", new Date()))); prop.put("showscheduledfeeds_list_" + apic + "_nextload", date_next_exec == null ? "" : DateFormat.getDateTimeInstance().format(date_next_exec)); prop.put("showscheduledfeeds_list_" + apic + "_lastcount", row.get("last_load_count", 0)); prop.put("showscheduledfeeds_list_" + apic + "_allcount", row.get("all_load_count", 0)); prop.put("showscheduledfeeds_list_" + apic + "_updperday", row.get("avg_upd_per_day", 0)); apic++; } else { // this is a new entry prop.put("shownewfeeds_list_" + newc + "_pk", UTF8.String(row.getPK())); prop.put("shownewfeeds_list_" + newc + "_count", newc); prop.putXML("shownewfeeds_list_" + newc + "_rss", messageurl); prop.putXML("shownewfeeds_list_" + newc + "_title", row.get("title", "")); prop.putXML("shownewfeeds_list_" + newc + "_referrer", referrer == null ? "" : referrer.toNormalform(true)); prop.put("shownewfeeds_list_" + newc + "_recording", DateFormat.getDateTimeInstance().format(row.get("recording_date", new Date()))); newc++; } if (apic > 1000 || newc > 1000) break; } prop.put("showscheduledfeeds_list", apic); prop.put("showscheduledfeeds_num", apic); prop.put("showscheduledfeeds", apic > 0 ? apic : 0); prop.put("shownewfeeds_list", newc); prop.put("shownewfeeds_num", newc); prop.put("shownewfeeds", newc > 0 ? 1 : 0); } catch (final IOException e) { ConcurrentLog.logException(e); } catch (final SpaceExceededException e) { ConcurrentLog.logException(e); } return prop; } prop.put("url", post.get("url", "")); int repeat_time = post.getInt("repeat_time", -1); final String repeat_unit = post.get("repeat_unit", "seldays"); // selminutes, selhours, seldays if (!"on".equals(post.get("repeat", "off")) && repeat_time > 0) repeat_time = -1; boolean record_api = false; DigestURL url = null; try { url = post.containsKey("url") ? new DigestURL(post.get("url", "")) : null; } catch (final MalformedURLException e) { ConcurrentLog.warn("Load_RSS", "url not well-formed: '" + post.get("url", "") + "'"); } ClientIdentification.Agent agent = post == null ? ClientIdentification.yacyInternetCrawlerAgent : ClientIdentification .getAgent(post.get("agentName", ClientIdentification.yacyInternetCrawlerAgentName)); // if we have an url then try to load the rss RSSReader rss = null; if (url != null) try { prop.put("url", url.toNormalform(true)); final Response response = sb.loader.load(sb.loader.request(url, true, false), CacheStrategy.NOCACHE, Integer.MAX_VALUE, BlacklistType.CRAWLER, agent); final byte[] resource = response == null ? null : response.getContent(); rss = resource == null ? null : RSSReader.parse(RSSFeed.DEFAULT_MAXSIZE, resource); } catch (final IOException e) { ConcurrentLog.warn("Load_RSS", e.getMessage()); prop.put("showerrmsg", 1); prop.put("showerrmsg_msgtxt", "no valid response from given url"); return prop; // if no response nothing to process further } // index all selected items: description only if (rss != null && post.containsKey("indexSelectedItemContent")) { final RSSFeed feed = rss.getFeed(); final Map<String, DigestURL> hash2UrlMap = new HashMap<String, DigestURL>(); loop: for (final Map.Entry<String, String> entry : post.entrySet()) { if (entry.getValue().startsWith(CHECKBOX_ITEM_PREFIX)) { /* Process selected item links */ final RSSMessage message = feed .getMessage(entry.getValue().substring(CHECKBOX_ITEM_PREFIX.length())); if (message == null || StringUtils.isBlank(message.getLink())) { /* Link element is optional in RSS 2.0 and Atom */ continue loop; } DigestURL messageUrl; try { messageUrl = new DigestURL(message.getLink()); } catch (MalformedURLException e) { ConcurrentLog.warn("Load_RSS", "Malformed feed item link URL : " + message.getLink()); continue loop; } if (RSSLoader.indexTriggered.containsKey(messageUrl.hash())) { continue loop; } hash2UrlMap.put(ASCII.String(messageUrl.hash()), messageUrl); } else if (entry.getValue().startsWith(CHECKBOX_MEDIA_ITEM_PREFIX)) { /* Process selected item enclosure (media) links */ final RSSMessage message = feed .getMessage(entry.getValue().substring(CHECKBOX_MEDIA_ITEM_PREFIX.length())); if (message == null || StringUtils.isBlank(message.getEnclosure())) { /* Enclosure element is optional */ continue loop; } DigestURL mediaUrl; try { mediaUrl = new DigestURL(message.getEnclosure()); } catch (MalformedURLException e) { ConcurrentLog.warn("Load_RSS", "Malformed feed item enclosure URL : " + message.getEnclosure()); continue loop; } if (RSSLoader.indexTriggered.containsKey(mediaUrl.hash())) { continue loop; } hash2UrlMap.put(ASCII.String(mediaUrl.hash()), mediaUrl); } } final List<DigestURL> urlsToIndex = new ArrayList<DigestURL>(); loop: for (final Map.Entry<String, DigestURL> entry : hash2UrlMap.entrySet()) { try { final DigestURL messageUrl = entry.getValue(); HarvestProcess harvestProcess = sb.urlExists(ASCII.String(messageUrl.hash())); if (harvestProcess != null) { continue loop; } urlsToIndex.add(messageUrl); RSSLoader.indexTriggered.insertIfAbsent(messageUrl.hash(), new Date()); } catch (final IOException e) { ConcurrentLog.logException(e); } } sb.addToIndex(urlsToIndex, null, null, collections, true); } if (rss != null && post.containsKey("indexAllItemContent")) { record_api = true; final RSSFeed feed = rss.getFeed(); RSSLoader.indexAllRssFeed(sb, url, feed, collections); } if (record_api && rss != null && rss.getFeed() != null && rss.getFeed().getChannel() != null) { // record API action RSSLoader.recordAPI(sb, post.get(WorkTables.TABLE_API_COL_APICALL_PK, null), url, rss.getFeed(), repeat_time, repeat_unit); } // show items from rss if (rss != null) { prop.put("showitems", 1); final RSSFeed feed = rss.getFeed(); final RSSMessage channel = feed.getChannel(); prop.putHTML("showitems_title", channel == null ? "" : channel.getTitle()); String author = channel == null ? "" : channel.getAuthor(); if (author == null || author.isEmpty()) author = channel == null ? "" : channel.getCopyright(); Date pubDate = channel == null ? null : channel.getPubDate(); prop.putHTML("showitems_author", author == null ? "" : author); prop.putHTML("showitems_description", channel == null ? "" : channel.getDescriptions().toString()); prop.putHTML("showitems_language", channel == null ? "" : channel.getLanguage()); prop.putHTML("showitems_date", (pubDate == null) ? "" : DateFormat.getDateTimeInstance().format(pubDate)); prop.putHTML("showitems_ttl", channel == null ? "" : channel.getTTL()); prop.put("showitems_docs", feed.size()); // number of documents int i = 0; for (final Hit item : feed) { DigestURL link = null; final String linkStr = item.getLink(); if (StringUtils.isNotBlank(linkStr)) { /* Link element is optional in RSS 2.0 and Atom */ try { link = new DigestURL(linkStr); } catch (final MalformedURLException e) { ConcurrentLog.warn("Load_RSS", "Malformed feed item link URL : " + linkStr); } } DigestURL enclosure = null; final String enclosureStr = item.getEnclosure(); if (StringUtils.isNotBlank(enclosureStr)) { try { enclosure = new DigestURL(enclosureStr); } catch (final MalformedURLException e) { ConcurrentLog.warn("Load_RSS", "Malformed feed item enclosure URL : " + enclosureStr); } } if (link == null) { /* No link in this feed item : we use the enclosure media URL as the main link */ link = enclosure; } author = item.getAuthor(); if (author == null) { author = item.getCopyright(); } pubDate = item.getPubDate(); HarvestProcess harvestProcess; try { if (link != null && StringUtils.isNotEmpty(item.getGuid())) { harvestProcess = sb.urlExists(ASCII.String(link.hash())); prop.put("showitems_item_" + i + "_hasLink", true); prop.putHTML("showitems_item_" + i + "_hasLink_link", link.toNormalform(true)); final int state = harvestProcess != null ? 2 : RSSLoader.indexTriggered.containsKey(link.hash()) ? 1 : 0; prop.put("showitems_item_" + i + "_state", state); prop.put("showitems_item_" + i + "_indexable", state == 0); prop.put("showitems_item_" + i + "_indexable_count", i); prop.putHTML("showitems_item_" + i + "_indexable_inputValue", (link == enclosure ? CHECKBOX_MEDIA_ITEM_PREFIX : CHECKBOX_ITEM_PREFIX) + item.getGuid()); } else { prop.put("showitems_item_" + i + "_state", 0); prop.put("showitems_item_" + i + "_indexable", false); prop.put("showitems_item_" + i + "_hasLink", false); } prop.putHTML("showitems_item_" + i + "_author", author == null ? "" : author); prop.putHTML("showitems_item_" + i + "_title", item.getTitle()); prop.putHTML("showitems_item_" + i + "_description", item.getDescriptions().toString()); prop.put("showitems_item_" + i + "_defaultMediaDesc", false); prop.putHTML("showitems_item_" + i + "_language", item.getLanguage()); prop.putHTML("showitems_item_" + i + "_date", (pubDate == null) ? "" : DateFormat.getDateTimeInstance().format(pubDate)); i++; } catch (IOException e) { ConcurrentLog.logException(e); } try { if (enclosure != null && enclosure != link && StringUtils.isNotEmpty(item.getGuid())) { harvestProcess = sb.urlExists(ASCII.String(enclosure.hash())); prop.put("showitems_item_" + i + "_hasLink", true); prop.putHTML("showitems_item_" + i + "_hasLink_link", enclosure.toNormalform(true)); final int state = harvestProcess != null ? 2 : RSSLoader.indexTriggered.containsKey(enclosure.hash()) ? 1 : 0; prop.put("showitems_item_" + i + "_state", state); prop.put("showitems_item_" + i + "_indexable", state == 0); prop.put("showitems_item_" + i + "_indexable_count", i); prop.putHTML("showitems_item_" + i + "_indexable_inputValue", "media_" + item.getGuid()); prop.putHTML("showitems_item_" + i + "_author", ""); prop.putHTML("showitems_item_" + i + "_title", item.getTitle()); prop.putHTML("showitems_item_" + i + "_description", ""); /* Description is already used for the main item link, use here a default one */ prop.put("showitems_item_" + i + "_defaultMediaDesc", true); prop.putHTML("showitems_item_" + i + "_language", ""); prop.putHTML("showitems_item_" + i + "_date", ""); i++; } } catch (IOException e) { ConcurrentLog.logException(e); } } prop.put("showitems_item", i); prop.put("showitems_num", i); prop.putHTML("showitems_rss", url.toNormalform(true)); if (i > 0) { prop.put("showload", 1); prop.put("showload_rss", url.toNormalform(true)); } } return prop; }
From source file:com.uwetrottmann.wpdisplay.ui.DisplayFragment.java
private void populateViews(StatusData data) { // temperature values setTemperature(textTempOutgoing, R.string.label_temp_outgoing, data.getTemperature(StatusData.Temperature.OUTGOING)); setTemperature(textTempReturn, R.string.label_temp_return, data.getTemperature(StatusData.Temperature.RETURN)); setTemperature(textTempOutdoors, R.string.label_temp_outdoors, data.getTemperature(StatusData.Temperature.OUTDOORS)); setTemperature(textTempReturnShould, R.string.label_temp_return_should, data.getTemperature(StatusData.Temperature.RETURN_SHOULD)); setTemperature(textTempWater, R.string.label_temp_water, data.getTemperature(StatusData.Temperature.WATER)); setTemperature(textTempWaterShould, R.string.label_temp_water_should, data.getTemperature(StatusData.Temperature.WATER_SHOULD)); setTemperature(textTempSourceIn, R.string.label_temp_source_in, data.getTemperature(StatusData.Temperature.SOURCE_IN)); setTemperature(textTempSourceOut, R.string.label_temp_source_out, data.getTemperature(StatusData.Temperature.SOURCE_OUT)); // time values setText(textTimeActive, R.string.label_time_pump_active, data.getTime(StatusData.Time.TIME_PUMP_ACTIVE)); setText(textTimeInactive, R.string.label_time_compressor_inactive, data.getTime(StatusData.Time.TIME_COMPRESSOR_NOOP)); setText(textTimeResting, R.string.label_time_rest, data.getTime(StatusData.Time.TIME_REST)); setText(textTimeReturnLower, R.string.label_time_return_lower, data.getTime(StatusData.Time.TIME_RETURN_LOWER)); setText(textTimeReturnHigher, R.string.label_time_return_higher, data.getTime(StatusData.Time.TIME_RETURN_HIGHER)); // text values setText(textState, R.string.label_operating_state, getContext().getString(data.getOperatingState())); setText(textFirmware, R.string.label_firmware, data.getFirmwareVersion()); textTime.setText(DateFormat.getDateTimeInstance().format(data.getTimestamp())); }
From source file:com.z299studio.pb.Settings.java
private SettingItemAdapter initSettings() { int itemSize = 19; if (Application.Options.mFpStatus != C.Fingerprint.UNKNOWN) { itemSize += 1;/*from w ww. j a v a 2 s . co m*/ } SettingItem[] items = new SettingItem[itemSize]; int index = 0; String desc; items[index++] = new SettingItem(0, getString(R.string.general), null); items[index++] = new SettingItemAction(R.string.import_data, getString(R.string.import_data), null) .setListener(mActionListener); items[index++] = new SettingItemAction(R.string.export_data, getString(R.string.export_data), null) .setListener(mActionListener); items[index++] = new SettingItemSwitch(R.string.show_ungrouped, getString(R.string.show_ungrouped), null) .setValue(Application.Options.mShowOther); items[index++] = new SettingItemSelection(R.string.theme, getString(R.string.theme), null) .setOptions(getResources().getStringArray(R.array.theme_names)) .setValue(Application.Options.mTheme); items[index++] = new SettingItemAction(R.string.guide, getString(R.string.guide), null) .setListener(mActionListener); items[index++] = new SettingItem(0, getString(R.string.sync), null); items[index++] = new SettingItemSelection(R.string.sync_server, getString(R.string.sync_server), null) .setOptions(getResources().getStringArray(R.array.sync_methods)) .setValue(Application.Options.mSync); if (Application.Options.mSyncTime.after(new Date(0L))) { DateFormat df = DateFormat.getDateTimeInstance(); desc = df.format(Application.Options.mSyncTime); } else { desc = getString(R.string.never); } items[index++] = new SettingItemAction(R.string.last_sync, getString(R.string.last_sync), desc) .setListener(mActionListener); items[index++] = new SettingItemSwitch(R.string.sync_msg, getString(R.string.sync_msg), null) .setValue(Application.Options.mSyncMsg); items[index++] = new SettingItem(0, getString(R.string.security), null); int lock_options[] = { 1000, 5 * 60 * 1000, 30 * 60 * 1000, 0 }; int selection = 0; int saved = Application.Options.mAutoLock; for (int i = 0; i < lock_options.length; ++i) { if (lock_options[i] == saved) { selection = i; } } items[index++] = new SettingItemSelection(R.string.auto_lock, getString(R.string.auto_lock), null) .setOptions(getResources().getStringArray(R.array.lock_options)).setValue(selection); items[index++] = new SettingItemSwitch(R.string.show_password, getString(R.string.show_password), null) .setValue(Application.Options.mAlwaysShowPwd); items[index++] = new SettingItemSwitch(R.string.warn_copy, getString(R.string.warn_copy), null) .setValue(Application.Options.mWarnCopyPwd); items[index++] = new SettingItemAction(R.string.change_pwd, getString(R.string.change_pwd), null) .setListener(mActionListener); if (Application.Options.mFpStatus != C.Fingerprint.UNKNOWN) { items[index++] = new SettingItemSwitch(R.string.fp_title, getString(R.string.fp_title), getString(R.string.fp_desc)).setValue(Application.Options.mFpStatus == C.Fingerprint.ENABLED); } items[index++] = new SettingItem(0, getString(R.string.about), null); items[index++] = new SettingItemAction(R.string.licence, getString(R.string.licence), null) .setListener(mActionListener); items[index++] = new SettingItemAction(R.string.credits, getString(R.string.credits), null) .setListener(mActionListener); String versionName; try { versionName = this.getPackageManager().getPackageInfo(getPackageName(), 0).versionName; } catch (PackageManager.NameNotFoundException e) { versionName = "2.2.0"; } desc = getString(R.string.version, versionName); items[index] = new SettingItemAction(R.string.build, getString(R.string.build), desc); mAdapter = new SettingItemAdapter(this, items); return mAdapter; }
From source file:com.eryansky.common.utils.DateUtil.java
public static boolean isDateBefore(String date2) { try {// w ww.java 2s. c om Date date1 = new Date(); DateFormat df = DateFormat.getDateTimeInstance(); return date1.before(df.parse(date2)); } catch (ParseException e) { System.out.print("[SYS] " + e.getMessage()); return false; } }