Created
December 24, 2019 11:52
-
-
Save sidishere/5737b0c4820c3b99218bc332cea612ee to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.helloworld; | |
import androidx.appcompat.app.AppCompatActivity; | |
import android.content.Intent; | |
import android.os.Bundle; | |
import android.util.Log; | |
import android.widget.TextView; | |
import java.util.Calendar; | |
public class DetailsActivity extends AppCompatActivity { | |
String[] strDays = { | |
"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", | |
"Saturday”s}; | |
Calendar myDOB=Calendar.getInstance(); | |
Calendar now=Calendar.getInstance(); | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_details); | |
TextView textview= findViewById(R.id.day); | |
Intent intent = getIntent(); | |
String dob=intent.getStringExtra("dateOfBirth"); | |
int year=Integer.parseInt(dob.substring(6,10)); | |
int month=Integer.parseInt(dob.substring(3,5))-1; | |
int day=Integer.parseInt(dob.substring(0,2)); | |
int curYear=now.get(Calendar.YEAR); | |
int curMonth=now.get(Calendar.MONTH); | |
int curday=now.get(Calendar.DATE); | |
myDOB.set(year,month,day); | |
now.set(curYear,curMonth,curday); | |
Log.i("A","Cur year"+curYear+" "+curMonth+" "+curday); | |
if(myDOB.compareTo(now)<=0) | |
textview.setText("You were born on "+strDays[myDOB.get(Calendar.DAY_OF_WEEK)-1]); | |
else | |
textview.setText("No wait you cant be here now and be born in the future."); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment