display date in human-readable format

remove invalid : character

change YYYY to yyyy
This commit is contained in:
Michael Beyeler 2018-01-31 15:18:07 -08:00
parent 2b62f1aa6d
commit a12074b0c6
1 changed files with 7 additions and 1 deletions

View File

@ -14,6 +14,9 @@ import com.simplemobiletools.draw.views.MyCanvas
import kotlinx.android.synthetic.main.dialog_save_image.view.*
import java.io.File
import java.io.OutputStream
import java.text.DateFormat
import java.text.SimpleDateFormat
import java.util.Date
class SaveImageDialog(val activity: SimpleActivity, val suggestedExtension: String, val curPath: String, val canvas: MyCanvas,
callback: (path: String, extension: String) -> Unit) {
@ -104,7 +107,10 @@ class SaveImageDialog(val activity: SimpleActivity, val suggestedExtension: Stri
}
private fun getInitialFilename(): String {
val defaultFilename = "image_${System.currentTimeMillis() / 1000}"
// Display date and time in human readable format:
val sdf = SimpleDateFormat("yyyy-MM-dd_HH-mm")
val defaultFilename = "image_${sdf.format(Date(System.currentTimeMillis()))}"
return if (curPath.isEmpty()) defaultFilename else curPath.getFilenameFromPath().substring(0, curPath.getFilenameFromPath().lastIndexOf("."))
}
}