[JAVA] Find the number of days in a month with Kotlin

You can easily find the number of days in a month by using the getActualMaximum method of the Calendar class. Until now, I added time stamps every day and looped until the month changed. .. ..

import java.util.*

fun main(args: Array<String>) {
    val calendar = Calendar.getInstance()
    val year = 2020
    val month = 2
    calendar.set(year, month - 1, 1) //Note that the month is specified starting from 0
    val maxDay = calendar.getActualMaximum(Calendar.DAY_OF_MONTH)
    print("${year}Year${month}The moon${maxDay}There is a day")

Recommended Posts

Find the number of days in a month with Kotlin
Program to find the number of days per month including leap years
Count the number of occurrences of a string in Ruby
A program that counts the number of words in a List
Find the difference from a multiple of 10
Generate a serial number with Hibernate (JPA) TableGenerator and store it in the Id of String.
Dynamically increase the number of elements in a Java 2D array (multidimensional array)
How to find the total number of pages when paging in Java
Measure the size of a folder in Java
Find the Fibonacci number with the Fork / Join Framework
I checked the number of taxis with Ruby
How to get the ID of a user authenticated with Firebase in Swift
Validate the identity token of a user authenticated with AWS Cognito in Java
[Swift] Get the number of steps with CMP edometer
CI the architecture of Java / Kotlin applications with ArchUnit
The story of making a reverse proxy with ProxyServlet
Find the remainder divided by 3 without using a number
Find the approximate value of log (1 + x) in Swift
Find the greatest common divisor and least common multiple of any number of integers in Ruby
Let's implement a function to limit the number of access to the API with SpringBoot + Redis
A quick explanation of the five types of static in Java
A summary of what Java programmers find when reading Kotlin source for the first time
Determine that the value is a multiple of 〇 in Ruby
A story packed with the basics of Spring Boot (solved)
Check the operation of two roles with a chat application
Find a subset in Java
Count the number of digits after the decimal point in Java
Explain the benefits of the State pattern with a movie rating
How to derive the last day of the month in Java
Display a balloon message in BarButtonItem of NavigationBar with a size according to the amount of text.
Implementation of HashMap in kotlin
[Swift] When you want to know if the number of characters in a String matches a certain number ...
I tried to express the result of before and after of Date class with a number line
Graph the sensor information of Raspberry Pi in Java and check it with a web browser
The basics of the process of making a call with an Android app
The story of the first Rails app refactored with a self-made helper
Try to imitate the idea of a two-dimensional array with a one-dimensional array
Get a proxy instance of the component itself in Spring Boot
Find out the list of fonts available in AWS Lambda + Java
{The first consecutive 10-digit prime number in the value of e} .com
A story about hitting the League Of Legends API with JAVA
Method to add the number of years and get the end of the month
Get the public URL of a private Flickr file in Java
A story that struggled with the introduction of Web Apple Pay
Let's create a TODO application in Java 5 Switch the display of TODO
A memorandum of the FizzBuzz problem
Place in the middle with css
Order of processing in the program
The guy who tries-with-resources with kotlin
Number of digits in numeric item
A fix to prevent the increase in the number of DB connections in the custom authentication provider of the Cognos SDK sample
What I don't like when using interface of a function with default arguments in Kotlin from Java
Make a daily build of the TOPPERS kernel with Gitlab and Docker
Use Priority Queue with Kotlin (1.0.0) of AtCoder (+ Investigate the environment of the judge server)
The story of forgetting to close a file in Java and failing
The story of making a game launcher with automatic loading function [Java]
Let's express the result of analyzing Java bytecode with a class diagram
Set the number of seconds for fast forward and rewind in ExoPlayer
How to change the maximum and maximum number of POST data in Spark
How to find out the Java version of a compiled class file
How to change the value of a variable at a breakpoint in intelliJ