Skip to content

Information Sources

Jacob Wong edited this page Oct 26, 2019 · 33 revisions

Extra Libraries

[TBD]

Why LocalDateTime?

  • Basically, the Date object is a [redacted] to use so they made it better.
  • For documentation purposes, the main reason for choosing the Java 8 Date/Time API is it's Ease of use and Ease of Understanding over the previous Date object.

Examples of Use:

LocalDate localDate = LocalDate.now();
LocalDate.of(2015, 02, 20);
LocalDate.parse("2015-02-20");

LocalDate tomorrow = LocalDate.now().plusDays(1);
localDateTime.minusHours(2);
DayOfWeek sunday = LocalDate.parse("2016-06-12").getDayOfWeek();
boolean leapYear = LocalDate.now().isLeapYear();

localDateTime.format(DateTimeFormatter.ofPattern("yyyy/MM/dd"));
String localDateString = localDateTime.format(DateTimeFormatter.ISO_DATE);

How to use Firestore

Steps to connect to Firestore and query the tables:

  1. Add the following line of code as an attribute for the class:
    FirebaseFirestore db = FirebaseFirestore.getInstance();
    Also need to add import statement for Firestore
    import com.google.firebase.firestore.FirebaseFirestore;
  2. (Optional) If we are referencing the same collection can add the following:
    final CollectionReference collectionReference = db.collection(collectionName);
  3. Then need to define a Hashmap to be used as the data to be saved/added to the Database
    HashMap<String, Object> data = new HashMap<>();
    data.put("integer", 123);
    data.put("string", "hello world");
    data.put("date", localdate);
  4. See the list of example queires below. Can also add OnSuccess/Failure Listeners

    Add Query

    collectionReference
    	.document(documentName)
    	.set(data);

    Delete Query

    collectionReference
    	.document(documentName)
    	.delete();

Borrowed/Referenced Code

Mohammad's Ridebook

Assets

References

Clone this wiki locally