Answers for "java get age from date of birth"

43

undo commit

# KEEP CHANGES
git reset --soft HEAD~1

# REMOVE CHANGES
git reset --hard HEAD~1
Posted by: Guest on April-07-2020
2

undo most recent commit

$ git commit -m "some comment"                
$ git reset HEAD~                                          
<< edit files as necessary >>                              
$ git add ...                                              
$ git commit -c ORIG_HEAD
Posted by: Guest on June-18-2020
1

revert last commit git

$ git commit -m "Something terribly misguided" # (0: Your Accident)
$ git reset HEAD~                              # (1)
[ edit files as necessary ]                    # (2)
$ git add .                                    # (3)
$ git commit -c ORIG_HEAD                      # (4)
Posted by: Guest on February-15-2021
-1

how to undo commit

git reset <commitId>
# Exemple
git reset 5310517
Posted by: Guest on October-21-2020
10

java age from date

LocalDate today = LocalDate.now();
LocalDate birthday = LocalDate.of(1987, 09, 24);

Period period = Period.between(birthday, today);

//Now access the values as below
System.out.println(period.getDays());
System.out.println(period.getMonths());
System.out.println(period.getYears());
Posted by: Guest on July-23-2020
0

how to calculate age from date of birth in java using calendar

package com.candidjava.time;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.Period;
import java.util.Calendar;
import java.util.Date;

public class DobConversion {
 public static void main(String[] args) throws ParseException {
  //direct age calculation 
  LocalDate l = LocalDate.of(1998, 04, 23); //specify year, month, date directly
  LocalDate now = LocalDate.now(); //gets localDate
  Period diff = Period.between(l, now); //difference between the dates is calculated
  System.out.println(diff.getYears() + "years" + diff.getMonths() + "months" + diff.getDays() + "days");

  //using Calendar Object
  String s = "1994/06/23";
  SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
  Date d = sdf.parse(s);
  Calendar c = Calendar.getInstance();
  c.setTime(d);
  int year = c.get(Calendar.YEAR);
  int month = c.get(Calendar.MONTH) + 1;
  int date = c.get(Calendar.DATE);
  LocalDate l1 = LocalDate.of(year, month, date);
  LocalDate now1 = LocalDate.now();
  Period diff1 = Period.between(l1, now1);
  System.out.println("age:" + diff1.getYears() + "years");
 }
}
Posted by: Guest on January-19-2021

Code answers related to "java get age from date of birth"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language