mirror of
https://github.com/KDE/kdeconnect-android
synced 2025-08-30 21:55:10 +00:00
Use Java 8 Date/Time API instead of the legacy API.
This commit is contained in:
@@ -55,8 +55,10 @@ import java.security.PublicKey;
|
||||
import java.security.cert.Certificate;
|
||||
import java.security.cert.CertificateException;
|
||||
import java.security.cert.X509Certificate;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDate;
|
||||
import java.time.ZoneId;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.Formatter;
|
||||
import java.util.Locale;
|
||||
@@ -126,16 +128,15 @@ public class SslHelper {
|
||||
nameBuilder.addRDN(BCStyle.CN, deviceId);
|
||||
nameBuilder.addRDN(BCStyle.OU, "KDE Connect");
|
||||
nameBuilder.addRDN(BCStyle.O, "KDE");
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.add(Calendar.YEAR, -1);
|
||||
Date notBefore = calendar.getTime();
|
||||
calendar.add(Calendar.YEAR, 10);
|
||||
Date notAfter = calendar.getTime();
|
||||
final LocalDate localDate = LocalDate.now().minusYears(1);
|
||||
final Instant notBefore = localDate.atStartOfDay(ZoneId.systemDefault()).toInstant();
|
||||
final Instant notAfter = localDate.plusYears(10).atStartOfDay(ZoneId.systemDefault())
|
||||
.toInstant();
|
||||
X509v3CertificateBuilder certificateBuilder = new JcaX509v3CertificateBuilder(
|
||||
nameBuilder.build(),
|
||||
BigInteger.ONE,
|
||||
notBefore,
|
||||
notAfter,
|
||||
Date.from(notBefore),
|
||||
Date.from(notAfter),
|
||||
nameBuilder.build(),
|
||||
publicKey
|
||||
);
|
||||
|
@@ -5,16 +5,16 @@ import android.net.Uri;
|
||||
import android.os.Environment;
|
||||
import android.provider.MediaStore;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.content.FileProvider;
|
||||
|
||||
import org.kde.kdeconnect.BackgroundService;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.content.FileProvider;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
public class PhotoActivity extends AppCompatActivity {
|
||||
|
||||
@@ -45,7 +45,7 @@ public class PhotoActivity extends AppCompatActivity {
|
||||
|
||||
private File createImageFile() throws IOException {
|
||||
// Create an image file name
|
||||
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
|
||||
String timeStamp = DateTimeFormatter.ofPattern("yyyyMMdd_HHmmss").format(LocalDateTime.now());
|
||||
String imageFileName = "JPEG_" + timeStamp + "_";
|
||||
File storageDir = getExternalFilesDir(Environment.DIRECTORY_PICTURES);
|
||||
return File.createTempFile(
|
||||
|
Reference in New Issue
Block a user