Answers for "java calendar get year"

1

calendar.year java

import java.time.LocalDate;  
import java.time.Year;  
public class YearExample{  
  public static void main(String[] args) {  
    Year y = Year.of(2017);  
    LocalDate l = y.atDay(123);  
    System.out.println(l);  
  }  
}
Posted by: Guest on September-03-2021
0

java get year from date

SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date = format.parse(datetime);
SimpleDateFormat df = new SimpleDateFormat("yyyy");
year = df.format(date);
Posted by: Guest on October-08-2020
1

java get year

import java.time.ZoneId;
import java.util.Date;

new Date().toInstant().atZone(ZoneId.systemDefault()).toLocalDate().getYear();
Posted by: Guest on September-03-2020

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language