List of usage examples for java.text DateFormat getTimeInstance
public static final DateFormat getTimeInstance()
From source file:com.example.vinoth.activitynavigator.GpsActivity.java
/** * Runs when a GoogleApiClient object successfully connects. *//* w w w . j av a 2 s.c om*/ @Override public void onConnected(Bundle connectionHint) { Log.i(TAG, "Connected to GoogleApiClient"); // If the initial location was never previously requested, we use // FusedLocationApi.getLastLocation() to get it. If it was previously requested, we store // its value in the Bundle and check for it in onCreate(). We // do not request it again unless the user specifically requests location updates by pressing // the Start Updates button. // // Because we cache the value of the initial location in the Bundle, it means that if the // user launches the activity, // moves to a new location, and then changes the device orientation, the original location // is displayed as the activity is re-created. if (mCurrentLocation == null) { if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { // TODO: Consider calling // ActivityCompat#requestPermissions // here to request the missing permissions, and then overriding // public void onRequestPermissionsResult(int requestCode, String[] permissions, // int[] grantResults) // to handle the case where the user grants the permission. See the documentation // for ActivityCompat#requestPermissions for more details. return; } mCurrentLocation = LocationServices.FusedLocationApi.getLastLocation(mGoogleApiClient); mLastUpdateTime = DateFormat.getTimeInstance().format(new Date()); updateUI(); } // If the user presses the Start Updates button before GoogleApiClient connects, we set // mRequestingLocationUpdates to true (see startUpdatesButtonHandler()). Here, we check // the value of mRequestingLocationUpdates and if it is true, we start location updates. if (mRequestingLocationUpdates) { startLocationUpdates(); } }
From source file:com.google.android.gms.location.sample.locationupdates.MainActivity.java
/** * Runs when a GoogleApiClient object successfully connects. *///from w ww. ja va2 s . c o m @Override public void onConnected(Bundle connectionHint) { Log.i(TAG, "Connected to GoogleApiClient"); // If the initial location was never previously requested, we use // FusedLocationApi.getLastLocation() to get it. If it was previously requested, we store // its value in the Bundle and check for it in onCreate(). We // do not request it again unless the user specifically requests location updates by pressing // the Start Updates button. // // Because we cache the value of the initial location in the Bundle, it means that if the // user launches the activity, // moves to a new location, and then changes the device orientation, the original location // is displayed as the activity is re-created. if (mCurrentLocation == null) { mCurrentLocation = LocationServices.FusedLocationApi.getLastLocation(mGoogleApiClient); mLastUpdateTime = DateFormat.getTimeInstance().format(new Date()); //Calendar c = Calendar.getInstance(); //int Hr24=c.get(Calendar.HOUR_OF_DAY); //int Min=c.get(Calendar.MINUTE); //int SEC=c.get(Calendar.SECOND); //mLastUpdateTime = String.valueOf(Hr24)+":"+String.valueOf(Min)+":"+String.valueOf(SEC); //new SimpleDateFormat("MM-dd-yyyy-kk-mm").format(new Date()); //updateUI(); } // If the user presses the Start Updates button before GoogleApiClient connects, we set // mRequestingLocationUpdates to true (see startUpdatesButtonHandler()). Here, we check // the value of mRequestingLocationUpdates and if it is true, we start location updates. if (mRequestingLocationUpdates) { startLocationUpdates(); } }
From source file:ro.tudorluca.gpstracks.android.MainActivity.java
/** * Callback that fires when the location changes. *//*from w w w. jav a 2 s. co m*/ @Override public void onLocationChanged(Location location) { mCurrentLocation = location; mLastUpdateTime = DateFormat.getTimeInstance().format(new Date()); updateUI(); Toast.makeText(this, getResources().getString(R.string.location_updated_message), Toast.LENGTH_SHORT) .show(); sendLocationToWebApi(location); }
From source file:com.googlemapapp.MainActivity.java
/** * Runs when a GoogleApiClient object successfully connects. *///from www. ja va 2 s .c om @Override public void onConnected(Bundle connectionHint) { Log.i(TAG, "Connected to GoogleApiClient"); // If the initial location was never previously requested, we use // FusedLocationApi.getLastLocation() to get it. If it was previously requested, we store // its value in the Bundle and check for it in onCreate(). We // do not request it again unless the user specifically requests location updates by pressing // the Start Updates button. // // Because we cache the value of the initial location in the Bundle, it means that if the // user launches the activity, // moves to a new location, and then changes the device orientation, the original location // is displayed as the activity is re-created. if (mCurrentLocation == null) { if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { // TODO: Consider calling // ActivityCompat#requestPermissions // here to request the missing permissions, and then overriding // public void onRequestPermissionsResult(int requestCode, String[] permissions, // int[] grantResults) // to handle the case where the user grants the permission. See the documentation // for ActivityCompat#requestPermissions for more details. return; } mCurrentLocation = LocationServices.FusedLocationApi.getLastLocation(mGoogleApiClient); mLastUpdateTime = DateFormat.getTimeInstance().format(new Date()); // updateUI(); } // If the user presses the Start Updates button before GoogleApiClient connects, we set // mRequestingLocationUpdates to true (see startUpdatesButtonHandler()). Here, we check // the value of mRequestingLocationUpdates and if it is true, we start location updates. if (mRequestingLocationUpdates) { startLocationUpdates(); } }
From source file:org.opendatakit.briefcase.util.ExportToCsv.java
private boolean emitSubmissionCsv(OutputStreamWriter osw, EncryptionInformation ei, Element submissionElement, TreeElement primarySet, TreeElement treeElement, boolean first, String uniquePath, File instanceDir) throws IOException { // OK -- group with at least one element -- assume no value... // TreeElement list has the begin and end tags for the nested groups. // Swallow the end tag by looking to see if the prior and current // field names are the same. TreeElement prior = null;/*from w w w.ja v a 2 s.com*/ for (int i = 0; i < treeElement.getNumChildren(); ++i) { TreeElement current = (TreeElement) treeElement.getChildAt(i); log.fine(" element name: " + current.getName()); if ((prior != null) && (prior.getName().equals(current.getName()))) { // it is the end-group tag... seems to happen with two adjacent repeat // groups log.info("repeating tag at " + i + " skipping " + current.getName()); prior = current; } else { Element ec = findElement(submissionElement, current.getName()); switch (current.getDataType()) { case org.javarosa.core.model.Constants.DATATYPE_TEXT:/** * Text question * type. */ case org.javarosa.core.model.Constants.DATATYPE_INTEGER:/** * Numeric * question type. These are numbers without decimal points */ case org.javarosa.core.model.Constants.DATATYPE_DECIMAL:/** * Decimal * question type. These are numbers with decimals */ case org.javarosa.core.model.Constants.DATATYPE_CHOICE:/** * This is a * question with alist of options where not more than one option can * be selected at a time. */ case org.javarosa.core.model.Constants.DATATYPE_CHOICE_LIST:/** * This is a * question with alist of options where more than one option can be * selected at a time. */ case org.javarosa.core.model.Constants.DATATYPE_BOOLEAN:/** * Question with * true and false answers. */ case org.javarosa.core.model.Constants.DATATYPE_BARCODE:/** * Question with * barcode string answer. */ default: case org.javarosa.core.model.Constants.DATATYPE_UNSUPPORTED: if (ec == null) { emitString(osw, first, null); } else { emitString(osw, first, getSubmissionValue(ei, current, ec)); } first = false; break; case org.javarosa.core.model.Constants.DATATYPE_DATE: /** * Date question type. This has only date component without time. */ if (ec == null) { emitString(osw, first, null); } else { String value = getSubmissionValue(ei, current, ec); if (value == null || value.length() == 0) { emitString(osw, first, null); } else { Date date = WebUtils.parseDate(value); DateFormat formatter = DateFormat.getDateInstance(); emitString(osw, first, formatter.format(date)); } } first = false; break; case org.javarosa.core.model.Constants.DATATYPE_TIME: /** * Time question type. This has only time element without date */ if (ec == null) { emitString(osw, first, null); } else { String value = getSubmissionValue(ei, current, ec); if (value == null || value.length() == 0) { emitString(osw, first, null); } else { Date date = WebUtils.parseDate(value); DateFormat formatter = DateFormat.getTimeInstance(); emitString(osw, first, formatter.format(date)); } } first = false; break; case org.javarosa.core.model.Constants.DATATYPE_DATE_TIME: /** * Date and Time question type. This has both the date and time * components */ if (ec == null) { emitString(osw, first, null); } else { String value = getSubmissionValue(ei, current, ec); if (value == null || value.length() == 0) { emitString(osw, first, null); } else { Date date = WebUtils.parseDate(value); DateFormat formatter = DateFormat.getDateTimeInstance(); emitString(osw, first, formatter.format(date)); } } first = false; break; case org.javarosa.core.model.Constants.DATATYPE_GEOPOINT: /** * Question with location answer. */ String compositeValue = (ec == null) ? null : getSubmissionValue(ei, current, ec); compositeValue = (compositeValue == null) ? null : compositeValue.trim(); // emit separate lat, long, alt, acc columns... if (compositeValue == null || compositeValue.length() == 0) { for (int count = 0; count < 4; ++count) { emitString(osw, first, null); first = false; } } else { String[] values = compositeValue.split(" "); for (String value : values) { emitString(osw, first, value); first = false; } for (int count = values.length; count < 4; ++count) { emitString(osw, first, null); first = false; } } break; case org.javarosa.core.model.Constants.DATATYPE_BINARY: /** * Question with external binary answer. */ String binaryFilename = getSubmissionValue(ei, current, ec); if (binaryFilename == null || binaryFilename.length() == 0) { emitString(osw, first, null); first = false; } else { if (exportMedia) { int dotIndex = binaryFilename.lastIndexOf("."); String namePart = (dotIndex == -1) ? binaryFilename : binaryFilename.substring(0, dotIndex); String extPart = (dotIndex == -1) ? "" : binaryFilename.substring(dotIndex); File binaryFile = new File(instanceDir, binaryFilename); String destBinaryFilename = binaryFilename; int version = 1; File destFile = new File(outputMediaDir, destBinaryFilename); while (destFile.exists()) { destBinaryFilename = namePart + "-" + (++version) + extPart; destFile = new File(outputMediaDir, destBinaryFilename); } if (binaryFile.exists()) { FileUtils.copyFile(binaryFile, destFile); } emitString(osw, first, MEDIA_DIR + File.separator + destFile.getName()); } else { emitString(osw, first, binaryFilename); } first = false; } break; case org.javarosa.core.model.Constants.DATATYPE_NULL: /* * for nodes that * have no data, * or data type * otherwise * unknown */ if (current.isRepeatable()) { if (prior == null || !current.getName().equals(prior.getName())) { // repeatable group... if (ec == null) { emitString(osw, first, null); first = false; } else { String uniqueGroupPath = uniquePath + "/" + getFullName(current, primarySet); emitString(osw, first, uniqueGroupPath); first = false; // first time processing this repeat group (ignore templates) List<Element> ecl = findElementList(submissionElement, current.getName()); emitRepeatingGroupCsv(ei, ecl, current, uniquePath, uniqueGroupPath, instanceDir); } } } else if (current.getNumChildren() == 0 && current != briefcaseLfd.getSubmissionElement()) { // assume fields that don't have children are string fields. if (ec == null) { emitString(osw, first, null); first = false; } else { emitString(osw, first, getSubmissionValue(ei, current, ec)); first = false; } } else { /* one or more children -- this is a non-repeating group */ first = emitSubmissionCsv(osw, ei, ec, primarySet, current, first, uniquePath, instanceDir); } break; } prior = current; } } return first; }
From source file:com.google.android.gms.location.sample.locationupdates.MainActivity.java
/** * Callback that fires when the location changes. *//*from w w w. ja v a 2s.c o m*/ @Override public void onLocationChanged(Location location) { mCurrentLocation = location; mLastUpdateTime = DateFormat.getTimeInstance().format(new Date()); updateUI(); Toast.makeText(this, getResources().getString(R.string.location_updated_message), Toast.LENGTH_SHORT) .show(); }
From source file:com.googlemapapp.MainActivity.java
/** * Callback that fires when the location changes. *///from w ww . ja v a 2 s . c o m @Override public void onLocationChanged(Location location) { mCurrentLocation = location; mLastUpdateTime = DateFormat.getTimeInstance().format(new Date()); LatLng latLngCurrent = new LatLng(mCurrentLocation.getLatitude(), mCurrentLocation.getLongitude()); if (!isMovedCamera) { isMovedCamera = true; mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(latLngCurrent, 10.0f)); } // updateUI(); // Toast.makeText(this, getResources().getString(R.string.location_updated_message), Toast.LENGTH_SHORT).show(); }
From source file:ftpclientgui.MainWindow.java
@Override public void actionPerformed(ActionEvent e) { if (e.getSource() == tmr) { this.labTime.setText(DateFormat.getTimeInstance().format(new Date())); }//from ww w . jav a2 s.c o m }
From source file:org.uva.itast.blended.omr.OMRProcessor.java
/** * @throws FileNotFoundException //from ww w .j ava 2 s . co m * */ private void logScanResults(OMRTemplate template, PageImage pageImg, File markedImageFile, File templateResultsFile) throws FileNotFoundException { String filePageName = pageImg.getName(); /** * Template may be undetected */ String detectedTemplateId = (template == null) ? "Undetected" : template.getSelectedPage().getFields().get(OMRUtils.TEMPLATEID_FIELDNAME).getValue(); String activityId = (template == null) ? "Undetected" : detectedTemplateId.substring(0, detectedTemplateId.length() - 1); // crop page number int pagenum = template == null ? -1 : template.getSelectedPageNumber(); File logfile = new File(getOutputdir(), "log.txt"); // Append to file log.txt PrintWriter out = new PrintWriter(new FileOutputStream(logfile, true)); out.println("[Job]"); out.println("SourceFile=" + filePageName); out.println("PageIndex=" + pagenum); out.println("OutputImagePath=" + markedImageFile.getAbsolutePath()); out.println("ActivityCode=" + activityId); out.println("ParsedResults=" + templateResultsFile); out.println("Timestamp=" + DateFormat.getTimeInstance().format(new Date())); out.close(); }
From source file:in.rade.armud.armudclient.MainActivity.java
/** * Runs when a GoogleApiClient object successfully connects. *//*w w w .j a v a 2s . c om*/ @Override public void onConnected(Bundle connectionHint) { Log.i(LOCATION_TAG, "Connected to GoogleApiClient"); // If the initial location was never previously requested, we use // FusedLocationApi.getLastLocation() to get it. If it was previously requested, we store // its value in the Bundle and check for it in onCreate(). We // do not request it again unless the user specifically requests location updates by pressing // the Start Updates button. // // Because we cache the value of the initial location in the Bundle, it means that if the // user launches the activity, // moves to a new location, and then changes the device orientation, the original location // is displayed as the activity is re-created. if (mCurrentLocation == null) { mCurrentLocation = LocationServices.FusedLocationApi.getLastLocation(mGoogleApiClient); mLastUpdateTime = DateFormat.getTimeInstance().format(new Date()); Log.d("onConnected", "talk with mud"); talkwithMUD(mCurrentLocation); //client.send("location 72.012 23.231"); updateUI(); } // If the user presses the Start Updates button before GoogleApiClient connects, we set // mRequestingLocationUpdates to true (see startUpdatesButtonHandler()). Here, we check // the value of mRequestingLocationUpdates and if it is true, we start location updates. if (mRequestingLocationUpdates) { startLocationUpdates(); } }