日付を取得できるようにしました

This commit is contained in:
磯野 2024-01-12 12:23:22 +09:00
parent 87c5af9f01
commit 8a7ab0b7a1

View File

@ -6,6 +6,7 @@ import androidx.core.app.ActivityCompat;
import androidx.core.app.NotificationCompat; import androidx.core.app.NotificationCompat;
import androidx.core.app.NotificationManagerCompat; import androidx.core.app.NotificationManagerCompat;
import android.annotation.SuppressLint;
import android.app.NotificationChannel; import android.app.NotificationChannel;
import android.app.NotificationManager; import android.app.NotificationManager;
import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothAdapter;
@ -17,6 +18,9 @@ import android.os.Vibrator;
import com.google.android.material.bottomnavigation.BottomNavigationView; import com.google.android.material.bottomnavigation.BottomNavigationView;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random; import java.util.Random;
import java.util.UUID; import java.util.UUID;
@ -25,6 +29,13 @@ public class MainActivity extends AppCompatActivity {
BluetoothManager bluetoothManager; BluetoothManager bluetoothManager;
BluetoothAdapter bluetoothAdapter; BluetoothAdapter bluetoothAdapter;
//日付を取得するやつ
public static String getNowDate() {
@SuppressLint("SimpleDateFormat") final DateFormat df = new SimpleDateFormat("yyy/MM/dd HH:mm:ss");
final Date date = new Date(System.currentTimeMillis());
return df.format(date);
}
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);