Office Hours — Today, December 5

Tuesday, December 3

Dec 5
9:50 AM
Mark M.
has entered the room
9:55 AM
Mark M.
turned on guest access
Guy
has entered the room
Guy
hello
Mark M.
hello, Guy!
how can I help you today?
10:00 AM
Guy
how do I find the difference between a time in a Date and the current time.
Mark M.
um, that is more of a Java question
Guy
View paste
			Date boiFormateddate = new SimpleDateFormat("yyyy-MM-dd",Locale.getDefault()).parse(boiLastupdate);
			Log.i(LOGTAG, "formated date: " + boiFormateddate);
			
			Calendar ct = Calendar.getInstance();
			Log.i(LOGTAG, "Current time: " + ct.getTime());
			
			// long diff = ct.getTime() - boiFormateddate.getTime();
Mark M.
calling getTime() on a Date returns the time associated with the Date, measured as milliseconds since the Unix epoch
calling getTime() on both Date values and subtracting them will give you the difference in those times, in milliseconds
Guy
how do I get the current time in Date type?
Mark M.
new Date()\
er, new Date()
10:05 AM
Guy
thanks.
View paste
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd",Locale.getDefault());
String currentDateandTime = sdf.format(new Date());
10:10 AM
Mark M.
if you have another question, feel free to ask
Guy
5 Hours ago I had a question about Shared Pref. but I solved it :-)
10:50 AM
Guy
has left the room
11:05 AM
Mark M.
turned off guest access

Tuesday, December 3

 

Office Hours

People in this transcript

  • Guy
  • Mark Murphy