score:12
Accepted answer
You can't.
Yes, import java.util.{Calendar => Cal}
is really your best bet.
Conceptually, Scala object
members are similar to static members of Java classes. This might suggest the following would work, but it doesn't since there are actually no singleton objects available for Java classes.
scala> val Cal = java.util.Calendar
<console>:13: error: object Calendar is not a value
val Cal = java.util.Calendar
^
Source: stackoverflow.com
Related Query
- How to access a Java static method from Scala given a type alias for that class it resides in
- How to invoke public static method for existing Java class instance from Scala?
- How to declare scala method so that it can be called from Java using varargs style
- no access to a java static method from scala
- Scala 2.12.4: Cannot access protected static Java method from another package anymore
- scala - how to access a case class method from another class?
- How to access a public static final member in a Java class from Scala?
- Access from Java a Scala object that inherits from a generic Java base class
- Calling Java method that doesn't take a generic type from Scala
- scala - How to call public static method defined in Java from Scala?
- How do I create a class hierarchy of typed factory method constructors and access them from Scala using abstract types?
- How to write a toCSV method for scala case class that would generate the csv string for the class?
- How can I make a scala method parameter type that is a collection of multiple types that can be converted to a given type?
- How does the Scala program compile, given that bindAndHandle method takes the first parameter of type Flow not Route?
- How to call a Scala method that has Numeric parameter from Java
- How do I access a "getter" of a Java method from a scala method?
- How do I access a Java static member from Scala with reflection?
- Cannot access a Java static method from Scala
- How to reach to static method from class instance for mock
- How to define a method in Scala that returns a Java object?
- Any way to obtain a Java class from a Scala (2.10) type tag or symbol?
- How to write copy() method for Simple Class in Scala
- How to call main method of a Scala program from the main method of a java program?
- How to refer to protected inner class in Scala when inheriting from Java (with byte code only)
- How to define a scala method with type param that cannot be Any
- How to add a factory method to an existing Java class in Scala
- How to get Scala annotations that are given to an argument of a method
- Calling a protected static Java method from Scala
- Scala Puzzle: enforcing that two function arguments are of the same type AND both are a subtype of a given class
- Calling Java Generic Typed Method from Scala gives a Type mismatch error : Scala
More Query from same tag
- How to check to see if a string is a decimal number in Scala
- Scala: Mocking and the Cake Pattern
- Spark's RDD.map() will not execute unless the item inside RDD is visited
- any UML tools for Scala
- Why does this not type check?
- play silhouette is not inserting password into database table
- Integration tests hangs when testing my API in ZIO + HTTP4S
- What can cause "Unexpected tree in genLoad" in a macro expansion?
- Understanding higher-kinded types - implementing trait functionality
- How to explain the following sentences about private[this] and variance?
- Scala view bounds that work with subtypes?
- Scalaz Task not starting
- Why does enablePlugins(DockerPlugin) from sbt-docker in Play project give "error: reference to DockerPlugin is ambiguous"?
- Typesafe generics using TypeTag (with safe cast)
- Hyphenated sub project names with new sbt 0.13 multi-project definition
- Parallel Stream in scala
- java.lang.NoSuchMethodError in Scalatra using Scalate with Markdown
- How to divide dataset in two parts based on filter in Spark-scala
- zipWithIndex not working as expected in Play! Framework template
- How to get full form validation error message without form helper in Play Framework 2?
- How to add a global variable into map operation?
- Convert implicit def to scala 3 given syntax
- Unable to install Scala IDE for Windows 7 32 bit machine
- Share generic between traits
- What operations are performed in bulk when using parallel collections? Strange behavior here
- Sort Array of structs in Spark DataFrame
- Unit test stream requests with SttpBackendStub
- Why does the Scala library only defines tuples up to Tuple22?
- Updating UI from a background thread in ScalaFX
- How to get ScalaTest correctly reporting tests results when using scalacheck with Propspec and PropertyCheck?