Androidでミリ秒を日付形式に変換するにはどうすればよいですか?
この例は、Androidでミリ秒を日付形式に変換する方法を示しています。
ステップ1 − Android Studioで新しいプロジェクトを作成し、[ファイル]⇒[新しいプロジェクト]に移動して、新しいプロジェクトを作成するために必要なすべての詳細を入力します。
ステップ2 −次のコードをres / layout/activity_main.xmlに追加します。
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="https://schemas.android.com/apk/res/android" xmlns:tools="https://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:padding="4dp" tools:context=".MainActivity"> <TextView android:textStyle="bold" android:textSize="24sp" android:id="@+id/textView" android:layout_width="match_parent" android:layout_height="wrap_content"/> </LinearLayout>
ステップ3 −次のコードをsrc / MainActivity.java
に追加しますimport androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;
import java.text.SimpleDateFormat;
public class MainActivity extends AppCompatActivity {
TextView textView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
textView = findViewById(R.id.textView);
getDate();
}
private void getDate() {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd/MM/yyyy");
String dateString = simpleDateFormat.format(9897546853323L);
textView.setText(String.format("Date: %s", dateString));
}
} ステップ4 −次のコードをandroidManifest.xmlに追加します
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="https://schemas.android.com/apk/res/android" package="app.com.sample"> <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme"> <activity android:name=".MainActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest>
アプリケーションを実行してみましょう。実際のAndroidモバイルデバイスをコンピューターに接続していると思います。 Android Studioからアプリを実行するには、プロジェクトのアクティビティファイルの1つを開き、ツールバーの[実行]アイコンをクリックします。オプションとしてモバイルデバイスを選択し、デフォルトの画面を表示するモバイルデバイスを確認します-
-
Androidでカラー整数を16進文字列に変換するにはどうすればよいですか?
この例は、Androidでの方法を示しています。 ステップ1 − Android Studioで新しいプロジェクトを作成し、[ファイル]⇒[新しいプロジェクト]に移動して、新しいプロジェクトを作成するために必要なすべての詳細を入力します。 ステップ2 −次のコードをres / layout/activity_main.xmlに追加します。 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="https://schemas.android.
-
Excel で一般形式を日付に変換する方法 (7 つの方法)
Microsoft Excel の日付形式を使用することは非常に一般的です。それらをさまざまな計算に使用します。日付は、Excel で不可欠な形式の 1 つです。 Excel は、一般形式を日付形式に変換するのに十分スマートです。ただし、日付が一般形式またはテキスト形式である場合があります。このチュートリアルでは、適切な例と適切な図を使用して、Excel で日付を一般形式から日付形式に変換する方法を示します。 この練習用ワークブックをダウンロードしてください。 Excel で一般的な形式を日付に変換する 7 つの便利な方法 ここでは、一般形式を日付形式に変換するための 7 つの便利で効果的