Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,844 questions

51,765 answers

573 users

How to format time hours-minutes-seconds in Scala

1 Answer

0 votes
import java.time.LocalTime
import java.time.format.DateTimeFormatter

object FormattedTimeApp {
  def main(args: Array[String]): Unit = {
    // Get the current time
    val currentTime: LocalTime = LocalTime.now()

    // Format the time as "HH:MM:SS"
    val formatter: DateTimeFormatter = DateTimeFormatter.ofPattern("HH:mm:ss")
    val formattedTime: String = currentTime.format(formatter)

    println(s"Formatted Time: $formattedTime")
  }
}



/*
run:
 
Formatted Time: 19:02:47
 
*/
 

 



answered Jul 22, 2025 by avibootz

Related questions

1 answer 71 views
1 answer 59 views
1 answer 65 views
1 answer 69 views
1 answer 71 views
1 answer 61 views
...