将创建签到部分的时间选择,设置成了24小时制

master
呗 呗 3 years ago
parent 81ba7cb270
commit fc12817d5b

@ -86,7 +86,6 @@ public class CheckCourseSign extends AppCompatActivity {
initPage();
}
private void initView(){
CommonUtils.changeStatusBar(CheckCourseSign.this);
@ -117,16 +116,13 @@ public class CheckCourseSign extends AppCompatActivity {
});
getCourseSignMsg();
shareImageHandler = new Handler(new Handler.Callback() {
@Override
public boolean handleMessage(@NonNull Message msg) {
if(msg.arg1 == 200){
Intent shareIntent = (Intent) msg.obj;
System.out.println("Here...............shareImageHandler.....");
startActivity(Intent.createChooser(shareIntent, "分享图片"));
}
return false;
shareImageHandler = new Handler(msg -> {
if(msg.arg1 == 200){
Intent shareIntent = (Intent) msg.obj;
System.out.println("Here...............shareImageHandler.....");
startActivity(Intent.createChooser(shareIntent, "分享图片"));
}
return false;
});
// 意图函数加载器
@ -174,13 +170,11 @@ public class CheckCourseSign extends AppCompatActivity {
ivCode.setVisibility(View.VISIBLE);
});
ivCodeBig.setOnLongClickListener(v12 -> {
Toast.makeText(CheckCourseSign.this, "长按", Toast.LENGTH_SHORT).show();
shareImage();
return true;
});
});
ivCode.setOnLongClickListener(v -> {
Toast.makeText(CheckCourseSign.this, "长按", Toast.LENGTH_SHORT).show();
shareImage();
return true;
});

@ -2,6 +2,7 @@ package com.example.stlink.activitys.fragmentChild.activityTeaHome;
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
@ -15,6 +16,7 @@ import androidx.activity.result.ActivityResultLauncher;
import androidx.activity.result.contract.ActivityResultContracts;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.AppCompatButton;
@ -33,6 +35,8 @@ import com.google.android.material.timepicker.MaterialTimePicker;
import com.google.android.material.timepicker.TimeFormat;
import java.text.ParseException;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Objects;
public class CreateSign extends AppCompatActivity {
@ -109,7 +113,7 @@ public class CreateSign extends AppCompatActivity {
Long curTimeStamp = System.currentTimeMillis();
String currTime = CommonUtils.stampToDate(String.valueOf(curTimeStamp), "yyyy-MM-dd-hh-mm-ss");
String currTime = CommonUtils.stampToDate(String.valueOf(curTimeStamp), "yyyy-MM-dd-HH-mm-ss");
String[] timeStrs = currTime.split("-");
currYear = Integer.parseInt(timeStrs[0]);
currMonth = Integer.parseInt(timeStrs[1]);
@ -119,7 +123,7 @@ public class CreateSign extends AppCompatActivity {
currSecond = Integer.parseInt(timeStrs[5]);
startTimePicker = new MaterialTimePicker.Builder()
.setTimeFormat(TimeFormat.CLOCK_12H)
.setTimeFormat(TimeFormat.CLOCK_24H)
.setHour(currHour)
.setMinute(currMin)
.setTitleText("开始时间选择")
@ -127,7 +131,7 @@ public class CreateSign extends AppCompatActivity {
.setNegativeButtonText("取消")
.build();
endTimePicker = new MaterialTimePicker.Builder()
.setTimeFormat(TimeFormat.CLOCK_12H)
.setTimeFormat(TimeFormat.CLOCK_24H)
.setHour(currHour)
.setMinute(currMin)
.setTitleText("结束时间选择")
@ -190,7 +194,7 @@ public class CreateSign extends AppCompatActivity {
startHour + ":" +
startMin + ":" + "00";
try {
startTimeStamp = Long.parseLong(CommonUtils.dateToStamp(startTime, "yyyy-MM-dd hh:mm:ss"));
startTimeStamp = Long.parseLong(CommonUtils.dateToStamp(startTime, "yyyy-MM-dd HH:mm:ss"));
} catch (ParseException e) {
e.printStackTrace();
}
@ -208,7 +212,7 @@ public class CreateSign extends AppCompatActivity {
endHour + ":" +
endMin + ":" + "00";
try {
endTimeStamp = Long.parseLong(CommonUtils.dateToStamp(endTime, "yyyy-MM-dd hh:mm:ss"));
endTimeStamp = Long.parseLong(CommonUtils.dateToStamp(endTime, "yyyy-MM-dd HH:mm:ss"));
} catch (ParseException e) {
e.printStackTrace();
}

@ -257,7 +257,7 @@ public class CommonUtils {
String res;
@SuppressLint("SimpleDateFormat")
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(fprmat);
simpleDateFormat.setTimeZone(TimeZone.getTimeZone("GMT+8:00"));
// simpleDateFormat.setTimeZone(TimeZone.getTimeZone("GMT+8:00"));
//如果它本来就是long类型的,则不用写这一步
long lt = Long.parseLong(s);
Date date = new Date(lt);

Loading…
Cancel
Save