Skip to content

Instantly share code, notes, and snippets.

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 {
@sidishere
sidishere / g7
Created December 24, 2019 11:51
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.");
@sidishere
sidishere / g6
Created December 24, 2019 11:50
myDOB.set(year,month,day);
now.set(curYear,curMonth,curday);
@sidishere
sidishere / g5
Created December 24, 2019 11:50
int curYear=now.get(Calendar.YEAR);
int curMonth=now.get(Calendar.MONTH);
int curday=now.get(Calendar.DATE);
@sidishere
sidishere / g4
Created December 24, 2019 11:49
Calendar myDOB=Calendar.getInstance();
Calendar now=Calendar.getInstance();
@sidishere
sidishere / g3
Created December 24, 2019 11:49
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));
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="16dp"
android:paddingRight="16dp">
    <TextView
android:id="@+id/day"
android:layout_height="wrap_content"
@sidishere
sidishere / g2
Created December 24, 2019 11:47
public void sendDOB(View view){
    Intent intent=new Intent(this,DetailsActivity.class);
    if (dob.matches(""))
        Toast.makeText(this, "Give me your correct birthday", Toast.LENGTH_SHORT).show();
    else {
        intent.putExtra("dateOfBirth",dob);
        startActivity(intent);
    }
}
@sidishere
sidishere / g1
Created December 24, 2019 11:47
if (dobField.getText().length()<10 || dobField.getText().length()>10) {
    dob="";
    message.setText(("Hey " + nameField.getText().toString() +
            ". You may wish to enter your birthday correctly.Your current birthday seems to be invalid"));
}
else {
    dob=dobField.getText().toString();
    message.setText(("Hey " + nameField.getText().toString() + ". You know " + monthsArray[Integer.parseInt(dobField.getText().toString().substring(3, 5)) - 1] +
            " is a really good month to start your journey on our planet."));
}
if (((nameField.getText().toString().trim().length())==0))
    message.setText("Tell me your name");
else if(dobField.getText().toString().length()==0)
    message.setText("Hello "+nameField.getText().toString()+". Plz tell me your birthday");
else
message.setText(("Hey " + nameField.getText().toString() + ". You know " + monthsArray[Integer.parseInt(dobField.getText().toString().substring(3, 5)) - 1] +
            " is a really good month to start your journey on our planet."));
}