Chanaka Fernando
Chanaka Fernando

Reputation: 2335

Get Date based on day count in Dart

I want to get this done in Dart language for Flutter framework. I'm very new for Dart. Bellow is the Java example of what I want to do. In brief, I want to get the date by passing a known year and day count of the year. Your help is highly appreciate.

Year year = Year.of( 2017 );
LocalDate localDate = year.atDay( 159 );
int dayOfYear = localDate.getDayOfYear() ;

Upvotes: 0

Views: 171

Answers (1)

Yann39
Yann39

Reputation: 15719

Simply add days to specified year starting from 1st of January :

DateTime year = DateTime(2017);
DateTime date = year.add(Duration(days: 159));
print(date);

Upvotes: 1

Related Questions