giornoSettimana

fun giornoSettimana(dataInput:String):Int
{
    //--- https://www.baeldung.com/java-get-day-of-week
    //--- number ranges from 1 (Sunday) to 7 (Saturday)
    /*
        1- SUNDAY- Domenica
        2- MONDAY- Lunedì
        3- TUESDAY- Martedì
        4- WEDNESDAY- Mercoledì
        5- THURSDAY- Giovedì
        6- FRIDAY- Venerdì
        7- SATURDAY- Sabato
    */
    val p_data = formattaData(dataInput)
    var gs:Int=0
    var data2:String = ""
    val sdf0: SimpleDateFormat = SimpleDateFormat("yyyy-MM-dd")
    try {
        var x: Date = sdf0.parse(p_data)
        data2 = sdf0.format(x)
        val c = Calendar.getInstance()
        c.time = x // yourdate is an object of type Date
        gs = c[Calendar.DAY_OF_WEEK]
    }
    catch(e: Exception) {
        data2 = "Data errata"
    }
    //
    return gs
}

Lascia un commento