Scala

50 / 53

Scala - Interaction with Java




Not able to play video? Try with vimeo

*Video Transcript: *

As discussed earlier, we can use Java libraries in Scala. Let's check it. Copy the code displayed on the screen. This code uses java.util and java.text libraries and returns the current date in the United States. Let's run the code. As you can see, the current date in the United States is printed on the screen.


Please login to comment

2 Comments

In this Program, Both the output of df and df.format(now) provides the same result. 

So we, can directly use the statement like return df right instead of return df.format(now). Is there any specific reason to use this statement ?

  Upvote    Share

The df.format(now) method returns a formatted string representation of the datetime object, while df alone returns the DateFormatter object itself.

  Upvote    Share