Your input represents a local date/time (2018-04-02 20:06:42
), and to get the elapsed time, you need to define which timezone you'll use.
The input corresponds to April 2nd 2018, at 8:06:42 PM, but where? Note that, in different parts of the world, 8 PM occurred in a different moment, depending on what timezone you are. Without knowing the exact timezone that the input refers to, it's impossible to compare it with "now".
If you have some way to figure out what's the timezone that corresponds to the input, then you can start doing something like this:
String input = "2018-04-02 20:06:42";
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
// use the timezone name. Example: "UTC", "America/New_York", "Europe/Berlin", etc
sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
Date date = sdf.parse(input);
// difference in milliseconds
long diffFromNow = System.currentTimeMillis() - date.getTime();
Another alternative (a better one, IMO), is to use java.time
(for API level 26), or threeten backport (for API level < 26 - see here how to configure it in Android):
DateTimeFormatter fmt = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
ZonedDateTime zdt = LocalDateTime
// parse date/time String
.parse(input, fmt)
// set to a timezone (for UTC, use ZoneOffset.UTC)
.atZone(ZoneId.of("America/New_York"));
// difference in milliseconds
long diffFromNow = ChronoUnit.MILLIS.between(Instant.now(), zdt.toInstant());