-4

What do these annotations mean in this Kotlin code in android?

@SuppressLint("SimpleDateFormat")
fun convertLongToDateString(systemTime: Long): String {
    return SimpleDateFormat("EEEE MMM-dd-yyyy' Time: 'HH:mm")
            .format(systemTime).toString()
}

@Entity(tablename = "daily_sleep_quality_table")
data class SleepNight(...)

    ....
    ....
Akhil Pandey
  • 67
  • 1
  • 8
  • i'm confused, you've tagged your own question with the tags `android-annotations` and `java-annotations` so you know that these _are_ annotations, what exactly is your question then ? – a_local_nobody Feb 05 '20 at 07:45
  • I just wanted to know what exactly do they do or mean in code. They look like Python decorators. – Akhil Pandey May 30 '20 at 21:52

3 Answers3

3

check this

@
- introduces an annotation
- introduces or references a loop label
- introduces or references a lambda label
- references a 'this' expression from an outer scope
- references an outer superclass

Victory
  • 1,184
  • 2
  • 11
  • 30
2

@ is a Java annotation, which also supported in Kotlin.

@SuppressLint("SimpleDateFormat")

@SuppressLint is an annotation used by the Android Lint tool. Lint will tell you whenever something in your code isn't optimal or may crash. By passing "SimpleDateFormat" there, you're suppressing all warnings that would tell you if you're using SimpleDateFormat in a wrong way.

@Entity(tablename = "daily_sleep_quality_table")

@Entity is annotation used by SQLite to marks a class as an Entity. If your using that in your class, SQLite will identify your class as an Entity with the specified table name.

Ezra Lazuardy
  • 406
  • 6
  • 17
1

Those are Java annotations which kotlin supports

Java annotations are 100% compatible with Kotlin

In your example @Entity

Specifies that the class is an entity. This annotation is applied to the entity class

Community
  • 1
  • 1
Ori Marko
  • 56,308
  • 23
  • 131
  • 233