Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9193519
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T21:11:05+00:00 2026-06-17T21:11:05+00:00

I have this code package com.lestijden; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import android.os.Bundle;

  • 0

I have this code

package com.lestijden;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.widget.TextView;

public class MainActivity extends Activity {

TextView Datum;
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    Datum = (TextView) findViewById(R.id.Tijd);

    Date today = Calendar.getInstance().getTime();
    SimpleDateFormat Formatter = new SimpleDateFormat("km");
    String folderName = Formatter.format(today);

    int result = folderName.compareTo("0");


    if (result > 815 ){
        double data = new Double("905") - new Double(folderName); 
        Datum.setText(Double.toString(data));
    }
    else if (result > 905){
        double data = new Double("955") - new Double(folderName); 
        Datum.setText(Double.toString(data));
    }

    else if (result > 955){
        double data = new Double("1045") - new Double(folderName); 
        Datum.setText(Double.toString(data));
    }

    else if (result > 1045){
        double data = new Double("1100") - new Double(folderName); 
        Datum.setText(Double.toString(data));
    }

    else if (result > 1100){
        double data = new Double("1150") - new Double(folderName); 
        Datum.setText(Double.toString(data));
    }
    else if (result > 1150){
        double data = new Double("1240") - new Double(folderName); 
        Datum.setText(Double.toString(data));
    }
    else if (result > 1240){
        double data = new Double("1310") - new Double(folderName); 
        Datum.setText(Double.toString(data));
    }
    else if (result > 1310){
        double data = new Double("1400") - new Double(folderName); 
        Datum.setText(Double.toString(data));
    }
    else if (result > 1400){
        double data = new Double("1450") - new Double(folderName); 
        Datum.setText(Double.toString(data));
    }
    else if (result > 1450){
        double data = new Double("1505") - new Double(folderName); 
        Datum.setText(Double.toString(data));
    }
    else if (result > 1505){
        double data = new Double("1555") - new Double(folderName); 
        Datum.setText(Double.toString(data));
    }
    else if (result > 1555){
        double data = new Double("1645") - new Double(folderName); 
        Datum.setText(Double.toString(data));

    }
}
}

I want it to work like this: if the time is for example 14:01. (1401) then it needs to make a calculation 1450 minus the current time (1401). and display the output (49) in a textview.

My textview does not display any output. how do i solve this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T21:11:06+00:00Added an answer on June 17, 2026 at 9:11 pm

    You should convert the Strings to time objects. Substract these two times and convert the result to a String.

    java.text.DateFormat df = new java.text.SimpleDateFormat("hh:mm");
    java.util.Date date1 = df.parse("14:01");
    java.util.Date date2 = df.parse("14:50");
    long diff = date2.getTime() - date1.getTime();
    

    Diff will be the time difference in milliseconds.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code package com.cerbertek; import java.util.ArrayList; import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory;
I have this code: package com.powergroupbd.timer; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.os.CountDownTimer;
I have this code below: package com.example.killall; import android.os.Bundle; import android.app.Activity; import android.view.Menu; import
I have this code: package com.problemio; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View;
I have this code: package com.problemio; import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; import java.util.ArrayList;
i have this code package com.tct.soundTouch; import android.app.Activity; import android.media.MediaPlayer; import android.os.Bundle; import android.view.MotionEvent;
I have this code: package com.example.pr; import android.media.MediaPlayer; public class Audio{ MediaPlayer mp; public
So, I have this code: package com.example.ponto_2d; import android.app.Activity; import android.view.Menu; import android.view.MotionEvent; import
I have this code, for a android app i'm working on: package com.exercise.AndroidInternetTxt; import
I have this simple java code: package com.androiddesktoptest.testtest; public class AndroidDesktopTestMain { public static

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.