Commit 78543acd8f842fb6eea80fa4b7084b989dcf6fbf
1 parent
18c99e74
报名页面性别,出生日期选择控件修改
Showing
8 changed files
with
859 additions
and
3 deletions
build.gradle
moudle_pedometer/build.gradle
| @@ -104,6 +104,7 @@ dependencies { | @@ -104,6 +104,7 @@ dependencies { | ||
| 104 | implementation "org.greenrobot:eventbus:$rootProject.eventBus" | 104 | implementation "org.greenrobot:eventbus:$rootProject.eventBus" |
| 105 | //EasyPermission | 105 | //EasyPermission |
| 106 | implementation "pub.devrel:easypermissions:$rootProject.easypermissions" | 106 | implementation "pub.devrel:easypermissions:$rootProject.easypermissions" |
| 107 | + implementation "com.jzxiang.pickerview:TimePickerDialog:$rootProject.TimePickerDialog" | ||
| 107 | 108 | ||
| 108 | implementation 'com.sothree.slidinguppanel:library:3.4.0' | 109 | implementation 'com.sothree.slidinguppanel:library:3.4.0' |
| 109 | 110 |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/frame/view/RegistrationInfoView.java
| @@ -5,15 +5,28 @@ import android.view.View; | @@ -5,15 +5,28 @@ import android.view.View; | ||
| 5 | 5 | ||
| 6 | import com.cnlive.moudle.pedometer.ui.activity.RunRaceDetailActivity; | 6 | import com.cnlive.moudle.pedometer.ui.activity.RunRaceDetailActivity; |
| 7 | import com.cnlive.moudle.pedometer.ui.fragment.RegistrationInfoFragment; | 7 | import com.cnlive.moudle.pedometer.ui.fragment.RegistrationInfoFragment; |
| 8 | +import com.cnlive.moudle.pedometer.utils.DateTimeUtil; | ||
| 9 | +import com.cnlive.strike.ui.widget.BottomMenuDialog; | ||
| 8 | import com.example.moudle_pedometer.R; | 10 | import com.example.moudle_pedometer.R; |
| 9 | import com.hannesdorfmann.mosby3.mvp.MvpView; | 11 | import com.hannesdorfmann.mosby3.mvp.MvpView; |
| 12 | +import com.jzxiang.pickerview.TimePickerDialog; | ||
| 13 | +import com.jzxiang.pickerview.data.Type; | ||
| 14 | +import com.jzxiang.pickerview.listener.OnDateSetListener; | ||
| 15 | + | ||
| 16 | +import java.text.ParseException; | ||
| 17 | +import java.text.SimpleDateFormat; | ||
| 18 | +import java.util.Calendar; | ||
| 19 | +import java.util.Date; | ||
| 20 | + | ||
| 21 | +import static com.baidu.mapapi.BMapManager.getContext; | ||
| 10 | 22 | ||
| 11 | /** | 23 | /** |
| 12 | * Created by hanyayun 019/05/29. | 24 | * Created by hanyayun 019/05/29. |
| 13 | */ | 25 | */ |
| 14 | -public class RegistrationInfoView implements MvpView { | 26 | +public class RegistrationInfoView implements MvpView, OnDateSetListener { |
| 15 | 27 | ||
| 16 | RegistrationInfoFragment fragment; | 28 | RegistrationInfoFragment fragment; |
| 29 | + private BottomMenuDialog sex; | ||
| 17 | 30 | ||
| 18 | public RegistrationInfoView(RegistrationInfoFragment fragment) { | 31 | public RegistrationInfoView(RegistrationInfoFragment fragment) { |
| 19 | this.fragment = fragment; | 32 | this.fragment = fragment; |
| @@ -26,15 +39,57 @@ public class RegistrationInfoView implements MvpView { | @@ -26,15 +39,57 @@ public class RegistrationInfoView implements MvpView { | ||
| 26 | fragment.binding.topbar.setTitle("填写报名信息"); | 39 | fragment.binding.topbar.setTitle("填写报名信息"); |
| 27 | fragment.binding.commitInfo.setOnClickListener(v -> fragment.commitInfo()); | 40 | fragment.binding.commitInfo.setOnClickListener(v -> fragment.commitInfo()); |
| 28 | fragment.binding.toLineDetail.setOnClickListener(v ->goLineDetail()); | 41 | fragment.binding.toLineDetail.setOnClickListener(v ->goLineDetail()); |
| 42 | + sex = new BottomMenuDialog.Builder(fragment.getActivity()) | ||
| 43 | + .addMenu("男", new View.OnClickListener() { | ||
| 44 | + @Override | ||
| 45 | + public void onClick(View v) { | ||
| 46 | + sex.dismiss(); | ||
| 47 | + fragment.binding.sexText.setText("性别(非必填) 男"); | ||
| 48 | + } | ||
| 49 | + }).addMenu("女", new View.OnClickListener() { | ||
| 50 | + @Override | ||
| 51 | + public void onClick(View v) { | ||
| 52 | + sex.dismiss(); | ||
| 53 | + fragment.binding.sexText.setText("性别(非必填) 女"); | ||
| 54 | + } | ||
| 29 | 55 | ||
| 56 | + }).create(fragment.getActivity()); | ||
| 30 | fragment.binding.chooseSex.setOnClickListener(v -> { | 57 | fragment.binding.chooseSex.setOnClickListener(v -> { |
| 31 | - | 58 | + sex.show(); |
| 32 | }); | 59 | }); |
| 33 | fragment.binding.chooseBirthday.setOnClickListener(v -> { | 60 | fragment.binding.chooseBirthday.setOnClickListener(v -> { |
| 34 | - | 61 | + fragment.pickerDialog = new TimePickerDialog.Builder() |
| 62 | + .setCallBack(this) | ||
| 63 | + .setCancelStringId("取消") | ||
| 64 | + .setSureStringId("确定") | ||
| 65 | + .setTitleStringId("") | ||
| 66 | + .setCyclic(false) | ||
| 67 | + .setCurrentMillseconds(System.currentTimeMillis()) | ||
| 68 | + .setMinMillseconds(getStringToDate()) | ||
| 69 | + .setThemeColor(getContext().getResources().getColor(R.color.green)) | ||
| 70 | + .setType(Type.YEAR_MONTH_DAY) | ||
| 71 | + .setWheelItemTextSize(12) | ||
| 72 | + .build(); | ||
| 73 | + fragment.pickerDialog.show(fragment.getFragmentManager(), "all"); | ||
| 35 | }); | 74 | }); |
| 36 | } | 75 | } |
| 37 | 76 | ||
| 77 | + | ||
| 78 | + private long getStringToDate() { | ||
| 79 | +// DateTimeUtil.currentDateParserLong() | ||
| 80 | + Calendar calendar = Calendar.getInstance(); | ||
| 81 | + calendar.add(Calendar.YEAR, -50); | ||
| 82 | + | ||
| 83 | + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); | ||
| 84 | + Date date = new Date(); | ||
| 85 | + try { | ||
| 86 | + date = dateFormat.parse(calendar.get(Calendar.YEAR) + "-1-1"); | ||
| 87 | + } catch (ParseException e) { | ||
| 88 | + e.printStackTrace(); | ||
| 89 | + } | ||
| 90 | + return date.getTime(); | ||
| 91 | + } | ||
| 92 | + | ||
| 38 | public void toResult(){ | 93 | public void toResult(){ |
| 39 | fragment.binding.registerLy.setVisibility(View.GONE); | 94 | fragment.binding.registerLy.setVisibility(View.GONE); |
| 40 | fragment.binding.resultLy.setVisibility(View.VISIBLE); | 95 | fragment.binding.resultLy.setVisibility(View.VISIBLE); |
| @@ -46,4 +101,10 @@ public class RegistrationInfoView implements MvpView { | @@ -46,4 +101,10 @@ public class RegistrationInfoView implements MvpView { | ||
| 46 | fragment.getActivity().setResult(1002, intent); | 101 | fragment.getActivity().setResult(1002, intent); |
| 47 | fragment.getActivity().finish(); | 102 | fragment.getActivity().finish(); |
| 48 | } | 103 | } |
| 104 | + | ||
| 105 | + @Override | ||
| 106 | + public void onDateSet(TimePickerDialog timePickerView, long millseconds) { | ||
| 107 | +// 生日(非必填) 未选择 | ||
| 108 | + fragment.binding.birthday.setText("生日(非必填) 未选择:"+DateTimeUtil.formatDateTime(millseconds, "yyyy年MM月dd日")); | ||
| 109 | + } | ||
| 49 | } | 110 | } |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/frame/view/RunRaceDetailFragmentView.java
| @@ -45,6 +45,7 @@ import com.cnlive.moudle.pedometer.ui.activity.PedometerMainActivity; | @@ -45,6 +45,7 @@ import com.cnlive.moudle.pedometer.ui.activity.PedometerMainActivity; | ||
| 45 | import com.cnlive.moudle.pedometer.ui.activity.RaceRecordActivity; | 45 | import com.cnlive.moudle.pedometer.ui.activity.RaceRecordActivity; |
| 46 | import com.cnlive.moudle.pedometer.ui.activity.RegistrationInfoActivity; | 46 | import com.cnlive.moudle.pedometer.ui.activity.RegistrationInfoActivity; |
| 47 | import com.cnlive.moudle.pedometer.ui.activity.RunningMapActivity; | 47 | import com.cnlive.moudle.pedometer.ui.activity.RunningMapActivity; |
| 48 | +import com.cnlive.moudle.pedometer.ui.activity.TakePartActivity; | ||
| 48 | import com.cnlive.moudle.pedometer.ui.fragment.RunMainFragment; | 49 | import com.cnlive.moudle.pedometer.ui.fragment.RunMainFragment; |
| 49 | import com.cnlive.moudle.pedometer.ui.fragment.RunRaceDetailFragment; | 50 | import com.cnlive.moudle.pedometer.ui.fragment.RunRaceDetailFragment; |
| 50 | import com.cnlive.moudle.pedometer.utils.BitmapUtil; | 51 | import com.cnlive.moudle.pedometer.utils.BitmapUtil; |
| @@ -224,6 +225,10 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { | @@ -224,6 +225,10 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { | ||
| 224 | fragment.binding.includePersonScore.findViewById(R.id.check_all_cord).setOnClickListener(v -> { | 225 | fragment.binding.includePersonScore.findViewById(R.id.check_all_cord).setOnClickListener(v -> { |
| 225 | RaceRecordActivity.newInstance(fragment.getActivity()); | 226 | RaceRecordActivity.newInstance(fragment.getActivity()); |
| 226 | }); | 227 | }); |
| 228 | + | ||
| 229 | + fragment.binding.includeStreet.fiveJoinPerson.setOnClickListener(v ->{ | ||
| 230 | + TakePartActivity.newInstance(fragment.getActivity()); | ||
| 231 | + }); | ||
| 227 | } | 232 | } |
| 228 | 233 | ||
| 229 | private void initMap() { | 234 | private void initMap() { |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/ui/fragment/RegistrationInfoFragment.java
| @@ -14,6 +14,7 @@ import com.cnlive.moudle.pedometer.frame.presenter.RegistrationInfoPresenter; | @@ -14,6 +14,7 @@ import com.cnlive.moudle.pedometer.frame.presenter.RegistrationInfoPresenter; | ||
| 14 | import com.cnlive.moudle.pedometer.frame.view.RegistrationInfoView; | 14 | import com.cnlive.moudle.pedometer.frame.view.RegistrationInfoView; |
| 15 | import com.example.moudle_pedometer.R; | 15 | import com.example.moudle_pedometer.R; |
| 16 | import com.example.moudle_pedometer.databinding.FragmentRegistrationInfoBinding; | 16 | import com.example.moudle_pedometer.databinding.FragmentRegistrationInfoBinding; |
| 17 | +import com.jzxiang.pickerview.TimePickerDialog; | ||
| 17 | 18 | ||
| 18 | /** | 19 | /** |
| 19 | * Created by hanyayun 019/05/29. | 20 | * Created by hanyayun 019/05/29. |
| @@ -21,6 +22,7 @@ import com.example.moudle_pedometer.databinding.FragmentRegistrationInfoBinding; | @@ -21,6 +22,7 @@ import com.example.moudle_pedometer.databinding.FragmentRegistrationInfoBinding; | ||
| 21 | public class RegistrationInfoFragment extends MvpBindingFragment<RegistrationInfoView, RegistrationInfoPresenter,Object, FragmentRegistrationInfoBinding> { | 22 | public class RegistrationInfoFragment extends MvpBindingFragment<RegistrationInfoView, RegistrationInfoPresenter,Object, FragmentRegistrationInfoBinding> { |
| 22 | 23 | ||
| 23 | 24 | ||
| 25 | + public TimePickerDialog pickerDialog; | ||
| 24 | public static RegistrationInfoFragment newInstance() { | 26 | public static RegistrationInfoFragment newInstance() { |
| 25 | RegistrationInfoFragment fragment = new RegistrationInfoFragment(); | 27 | RegistrationInfoFragment fragment = new RegistrationInfoFragment(); |
| 26 | return fragment; | 28 | return fragment; |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/utils/DateTimeUtil.java
0 → 100644
| 1 | +package com.cnlive.moudle.pedometer.utils; | ||
| 2 | + | ||
| 3 | +import android.annotation.SuppressLint; | ||
| 4 | +import android.util.Log; | ||
| 5 | + | ||
| 6 | +import java.text.DateFormat; | ||
| 7 | +import java.text.ParseException; | ||
| 8 | +import java.text.ParsePosition; | ||
| 9 | +import java.text.SimpleDateFormat; | ||
| 10 | +import java.util.Calendar; | ||
| 11 | +import java.util.Date; | ||
| 12 | + | ||
| 13 | +/** | ||
| 14 | + * 时间、日期工具类 | ||
| 15 | + * Created by fanji on 2017/7/19. | ||
| 16 | + */ | ||
| 17 | + | ||
| 18 | +public class DateTimeUtil { | ||
| 19 | + | ||
| 20 | + static SimpleDateFormat format; | ||
| 21 | + | ||
| 22 | + /** | ||
| 23 | + * 日期格式:yyyy-MM-dd HH:mm:ss | ||
| 24 | + **/ | ||
| 25 | + public static final String DF_YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss"; | ||
| 26 | + | ||
| 27 | + /** | ||
| 28 | + * 日期格式:yyyy-MM-dd HH:mm | ||
| 29 | + **/ | ||
| 30 | + public static final String DF_YYYY_MM_DD_HH_MM = "yyyy-MM-dd HH:mm"; | ||
| 31 | + // yyyy-MM-dd-HH-mm | ||
| 32 | + | ||
| 33 | + /** | ||
| 34 | + * 日期格式:yyyy-MM-dd | ||
| 35 | + **/ | ||
| 36 | + public static final String DF_YYYY_MM_DD = "yyyy-MM-dd"; | ||
| 37 | + | ||
| 38 | + /** | ||
| 39 | + * 日期格式:HH:mm:ss | ||
| 40 | + **/ | ||
| 41 | + public static final String DF_HH_MM_SS = "HH:mm:ss"; | ||
| 42 | + | ||
| 43 | + /** | ||
| 44 | + * 日期格式:HH:mm | ||
| 45 | + **/ | ||
| 46 | + public static final String DF_HH_MM = "HH:mm"; | ||
| 47 | + | ||
| 48 | + private final static long minute = 60 * 1000;// 1分钟 | ||
| 49 | + private final static long hour = 60 * minute;// 1小时 | ||
| 50 | + private final static long day = 24 * hour;// 1天 | ||
| 51 | + private final static long month = 31 * day;// 月 | ||
| 52 | + private final static long year = 12 * month;// 年 | ||
| 53 | + | ||
| 54 | + | ||
| 55 | + public DateTimeUtil() { | ||
| 56 | + | ||
| 57 | + } | ||
| 58 | + | ||
| 59 | + /** | ||
| 60 | + * 将日期格式化成友好的字符串:几分钟前、几小时前、几天前、几月前、几年前、刚刚 | ||
| 61 | + * | ||
| 62 | + * @param date | ||
| 63 | + * @return | ||
| 64 | + */ | ||
| 65 | + public static String formatFriendly(Date date) { | ||
| 66 | + if (date == null) { | ||
| 67 | + return null; | ||
| 68 | + } | ||
| 69 | + long diff = new Date().getTime() - date.getTime(); | ||
| 70 | + long r = 0; | ||
| 71 | + if (diff > year) { | ||
| 72 | + r = (diff / year); | ||
| 73 | + return r + "年前"; | ||
| 74 | + } | ||
| 75 | + if (diff > month) { | ||
| 76 | + r = (diff / month); | ||
| 77 | + return r + "个月前"; | ||
| 78 | + } | ||
| 79 | + if (diff > day) { | ||
| 80 | + r = (diff / day); | ||
| 81 | + return r + "天前"; | ||
| 82 | + } | ||
| 83 | + if (diff > hour) { | ||
| 84 | + r = (diff / hour); | ||
| 85 | + return r + "个小时前"; | ||
| 86 | + } | ||
| 87 | + if (diff > minute) { | ||
| 88 | + r = (diff / minute); | ||
| 89 | + return r + "分钟前"; | ||
| 90 | + } | ||
| 91 | + return "刚刚"; | ||
| 92 | + } | ||
| 93 | + | ||
| 94 | + /** | ||
| 95 | + * 生活圈模仿微信时间展示样式 | ||
| 96 | + * | ||
| 97 | + * @param date | ||
| 98 | + * @return | ||
| 99 | + */ | ||
| 100 | + public static String formatNewFriendly(Date date) { | ||
| 101 | + if (date == null) { | ||
| 102 | + return null; | ||
| 103 | + } | ||
| 104 | + long diff = new Date().getTime() - date.getTime(); | ||
| 105 | + long r = 0; | ||
| 106 | + if (diff > day) { | ||
| 107 | + r = (diff / day); | ||
| 108 | + if (r==1){ | ||
| 109 | + return"昨天"; | ||
| 110 | + }else { | ||
| 111 | + return r + "天前"; | ||
| 112 | + } | ||
| 113 | + } | ||
| 114 | + if (diff > hour) { | ||
| 115 | + r = (diff / hour); | ||
| 116 | + return r + "小时前"; | ||
| 117 | + } | ||
| 118 | + if (diff > minute) { | ||
| 119 | + r = (diff / minute); | ||
| 120 | + return r + "分钟前"; | ||
| 121 | + } | ||
| 122 | + return "1分钟前"; | ||
| 123 | + } | ||
| 124 | + | ||
| 125 | + /** | ||
| 126 | + * 将日期以yyyy-MM-dd HH:mm:ss格式化 | ||
| 127 | + * | ||
| 128 | + * @param dateL 日期 | ||
| 129 | + * @return | ||
| 130 | + */ | ||
| 131 | + @SuppressLint("SimpleDateFormat") | ||
| 132 | + public static String formatDateTime(long dateL) { | ||
| 133 | + SimpleDateFormat sdf = new SimpleDateFormat(DF_YYYY_MM_DD_HH_MM_SS); | ||
| 134 | + Date date = new Date(dateL); | ||
| 135 | + return sdf.format(date); | ||
| 136 | + } | ||
| 137 | + | ||
| 138 | + /** | ||
| 139 | + * 将日期以yyyy-MM-dd HH:mm:ss格式化 | ||
| 140 | + * | ||
| 141 | + * @param dateL 日期 | ||
| 142 | + * @return | ||
| 143 | + */ | ||
| 144 | + @SuppressLint("SimpleDateFormat") | ||
| 145 | + public static String formatDateTime(long dateL, String pattern) { | ||
| 146 | + SimpleDateFormat sdf = new SimpleDateFormat(pattern); | ||
| 147 | + Date date = new Date(dateL); | ||
| 148 | + return sdf.format(date); | ||
| 149 | + } | ||
| 150 | + | ||
| 151 | + | ||
| 152 | + /** | ||
| 153 | + * 将日期以yyyy-MM-dd HH:mm:ss格式化 | ||
| 154 | + * | ||
| 155 | + * @param date 日期 | ||
| 156 | + * @param formater | ||
| 157 | + * @return | ||
| 158 | + */ | ||
| 159 | + @SuppressLint("SimpleDateFormat") | ||
| 160 | + public static String formatDateTime(Date date, String formater) { | ||
| 161 | + SimpleDateFormat sdf = new SimpleDateFormat(formater); | ||
| 162 | + return sdf.format(date); | ||
| 163 | + } | ||
| 164 | + | ||
| 165 | + /** | ||
| 166 | + * 将日期字符串转成日期 | ||
| 167 | + * | ||
| 168 | + * @param strDate 字符串日期 | ||
| 169 | + * @return java.util.date日期类型 | ||
| 170 | + */ | ||
| 171 | + @SuppressLint("SimpleDateFormat") | ||
| 172 | + public static Date parseDate(String strDate) { | ||
| 173 | + DateFormat dateFormat = new SimpleDateFormat(DF_YYYY_MM_DD_HH_MM_SS); | ||
| 174 | + Date returnDate = null; | ||
| 175 | + try { | ||
| 176 | + returnDate = dateFormat.parse(strDate); | ||
| 177 | + } catch (ParseException e) { | ||
| 178 | + | ||
| 179 | + } | ||
| 180 | + return returnDate; | ||
| 181 | + | ||
| 182 | + } | ||
| 183 | + | ||
| 184 | + /** | ||
| 185 | + * 获取系统当前日期 | ||
| 186 | + * | ||
| 187 | + * @return | ||
| 188 | + */ | ||
| 189 | + public static Date gainCurrentDate() { | ||
| 190 | + return new Date(); | ||
| 191 | + } | ||
| 192 | + | ||
| 193 | + /** | ||
| 194 | + * 验证日期是否比当前日期早 | ||
| 195 | + * | ||
| 196 | + * @param target1 比较时间1 | ||
| 197 | + * @param target2 比较时间2 | ||
| 198 | + * @return true 则代表target1比target2晚或等于target2,否则比target2早 | ||
| 199 | + */ | ||
| 200 | + public static boolean compareDate(Date target1, Date target2) { | ||
| 201 | + boolean flag = false; | ||
| 202 | + try { | ||
| 203 | + String target1DateTime = formatDateTime(target1, DF_YYYY_MM_DD_HH_MM_SS); | ||
| 204 | + String target2DateTime = formatDateTime(target2, DF_YYYY_MM_DD_HH_MM_SS); | ||
| 205 | + if (target1DateTime.compareTo(target2DateTime) <= 0) { | ||
| 206 | + flag = true; | ||
| 207 | + } | ||
| 208 | + } catch (Exception e) { | ||
| 209 | + System.out.println("比较失败,原因:" + e.getMessage()); | ||
| 210 | + } | ||
| 211 | + return flag; | ||
| 212 | + } | ||
| 213 | + | ||
| 214 | + /** | ||
| 215 | + * 对日期进行增加操作 | ||
| 216 | + * | ||
| 217 | + * @param target 需要进行运算的日期 | ||
| 218 | + * @param hour 小时 | ||
| 219 | + * @return | ||
| 220 | + */ | ||
| 221 | + public static Date addDateTime(Date target, double hour) { | ||
| 222 | + if (null == target || hour < 0) { | ||
| 223 | + return target; | ||
| 224 | + } | ||
| 225 | + | ||
| 226 | + return new Date(target.getTime() + (long) (hour * 60 * 60 * 1000)); | ||
| 227 | + } | ||
| 228 | + | ||
| 229 | + /** | ||
| 230 | + * 对日期进行相减操作 | ||
| 231 | + * | ||
| 232 | + * @param target 需要进行运算的日期 | ||
| 233 | + * @param hour 小时 | ||
| 234 | + * @return | ||
| 235 | + */ | ||
| 236 | + public static Date subDateTime(Date target, double hour) { | ||
| 237 | + if (null == target || hour < 0) { | ||
| 238 | + return target; | ||
| 239 | + } | ||
| 240 | + | ||
| 241 | + return new Date(target.getTime() - (long) (hour * 60 * 60 * 1000)); | ||
| 242 | + } | ||
| 243 | + | ||
| 244 | + /** | ||
| 245 | + * 获取系统时间的方法:月/日 时:分:秒 | ||
| 246 | + */ | ||
| 247 | + public static String getFormateDate() { | ||
| 248 | + Calendar calendar = Calendar.getInstance(); | ||
| 249 | + int month = (calendar.get(Calendar.MONTH) + 1); | ||
| 250 | + int day = calendar.get(Calendar.DAY_OF_MONTH); | ||
| 251 | + int hour = calendar.get(Calendar.HOUR_OF_DAY); | ||
| 252 | + int minute = calendar.get(Calendar.MINUTE); | ||
| 253 | + int second = calendar.get(Calendar.SECOND); | ||
| 254 | + | ||
| 255 | + String systemTime = (month < 10 ? "0" + month : month) + "/" + (day < 10 ? "0" + day : day) + " " + (hour < 10 ? "0" + hour : hour) + ":" + (minute < 10 ? "0" + minute : minute) + ":" + (second < 10 ? "0" + second : second); | ||
| 256 | + return systemTime; | ||
| 257 | + } | ||
| 258 | + | ||
| 259 | + /** | ||
| 260 | + * 获取系统时间的方法:时:分:秒 | ||
| 261 | + */ | ||
| 262 | + public static String getHourAndMinute() { | ||
| 263 | + Calendar calendar = Calendar.getInstance(); | ||
| 264 | + int hour = calendar.get(Calendar.HOUR_OF_DAY); | ||
| 265 | + int minute = calendar.get(Calendar.MINUTE); | ||
| 266 | + return (hour < 10 ? "0" + hour : hour) + ":" + (minute < 10 ? "0" + minute : minute); | ||
| 267 | + } | ||
| 268 | + | ||
| 269 | + /** | ||
| 270 | + * 获取分钟 | ||
| 271 | + */ | ||
| 272 | + public static int getMinute() { | ||
| 273 | + Calendar calendar = Calendar.getInstance(); | ||
| 274 | + int hour = calendar.get(Calendar.HOUR_OF_DAY); | ||
| 275 | + int minute = calendar.get(Calendar.MINUTE); | ||
| 276 | + return minute; | ||
| 277 | + } | ||
| 278 | + | ||
| 279 | + /** | ||
| 280 | + * 获取系统时间的方法:时 | ||
| 281 | + */ | ||
| 282 | + public static String getHour() { | ||
| 283 | + Calendar calendar = Calendar.getInstance(); | ||
| 284 | + int hour = calendar.get(Calendar.HOUR_OF_DAY); | ||
| 285 | + return ((hour < 10 ? "0" + hour : hour) + ""); | ||
| 286 | + } | ||
| 287 | + | ||
| 288 | + /** | ||
| 289 | + * 将2017-07-10 00:00:00 换2017-07-10 | ||
| 290 | + * | ||
| 291 | + * @param strDate | ||
| 292 | + * @return | ||
| 293 | + */ | ||
| 294 | + public static String strFormatStr(String strDate) { | ||
| 295 | + if (strDate.equals("")) { | ||
| 296 | + return ""; | ||
| 297 | + } | ||
| 298 | + return dateToStr(strToDate(strDate)); | ||
| 299 | + } | ||
| 300 | + | ||
| 301 | + /** | ||
| 302 | + * 2015-01-07 15:05:34 | ||
| 303 | + * | ||
| 304 | + * @param strDate | ||
| 305 | + * @return | ||
| 306 | + */ | ||
| 307 | + @SuppressLint("SimpleDateFormat") | ||
| 308 | + public static Date strToDateHHMMSS(String strDate) { | ||
| 309 | + SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | ||
| 310 | + ParsePosition pos = new ParsePosition(0); | ||
| 311 | + Date strtodate = formatter.parse(strDate, pos); | ||
| 312 | + return strtodate; | ||
| 313 | + } | ||
| 314 | + | ||
| 315 | + /** | ||
| 316 | + * 2015-01-07 15:05 | ||
| 317 | + * | ||
| 318 | + * @param strDate | ||
| 319 | + * @return | ||
| 320 | + */ | ||
| 321 | + @SuppressLint("SimpleDateFormat") | ||
| 322 | + public static Date strToDateHHMM(String strDate) { | ||
| 323 | + SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm"); | ||
| 324 | + ParsePosition pos = new ParsePosition(0); | ||
| 325 | + Date strtodate = formatter.parse(strDate, pos); | ||
| 326 | + return strtodate; | ||
| 327 | + } | ||
| 328 | + | ||
| 329 | + /** | ||
| 330 | + * 2015-01-07 | ||
| 331 | + * | ||
| 332 | + * @param strDate | ||
| 333 | + * @return | ||
| 334 | + */ | ||
| 335 | + @SuppressLint("SimpleDateFormat") | ||
| 336 | + public static Date strToDate(String strDate) { | ||
| 337 | + SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); | ||
| 338 | + ParsePosition pos = new ParsePosition(0); | ||
| 339 | + Date strtodate = formatter.parse(strDate, pos); | ||
| 340 | + return strtodate; | ||
| 341 | + } | ||
| 342 | + | ||
| 343 | + /** | ||
| 344 | + * 2015.01.07 | ||
| 345 | + * | ||
| 346 | + * @param strDate | ||
| 347 | + * @return | ||
| 348 | + */ | ||
| 349 | + @SuppressLint("SimpleDateFormat") | ||
| 350 | + public static Date strToDateDorp(String strDate) { | ||
| 351 | + SimpleDateFormat formatter = new SimpleDateFormat("yyyy.MM.dd"); | ||
| 352 | + ParsePosition pos = new ParsePosition(0); | ||
| 353 | + Date strtodate = formatter.parse(strDate, pos); | ||
| 354 | + return strtodate; | ||
| 355 | + } | ||
| 356 | + | ||
| 357 | + @SuppressLint("SimpleDateFormat") | ||
| 358 | + public static String dateToStr(Date dateDate) { | ||
| 359 | + SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); | ||
| 360 | + String dateString = formatter.format(dateDate); | ||
| 361 | + return dateString; | ||
| 362 | + } | ||
| 363 | + | ||
| 364 | + /** | ||
| 365 | + * 传入一个String转化为long | ||
| 366 | + */ | ||
| 367 | + @SuppressLint("SimpleDateFormat") | ||
| 368 | + public static Long stringParserLong(String param) throws ParseException { | ||
| 369 | + format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | ||
| 370 | + return format.parse(param).getTime(); | ||
| 371 | + } | ||
| 372 | + | ||
| 373 | + /** | ||
| 374 | + * 传入一个String转化为long | ||
| 375 | + */ | ||
| 376 | + @SuppressLint("SimpleDateFormat") | ||
| 377 | + public static Long stringParserLong1(String param) throws ParseException { | ||
| 378 | + format = new SimpleDateFormat("yyyyMMddHHmmss"); | ||
| 379 | + return format.parse(param).getTime(); | ||
| 380 | + } | ||
| 381 | + | ||
| 382 | + /** | ||
| 383 | + * 当前时间转换为long | ||
| 384 | + */ | ||
| 385 | + @SuppressLint("SimpleDateFormat") | ||
| 386 | + public static Long currentDateParserLong() throws ParseException { | ||
| 387 | + format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | ||
| 388 | + return format.parse(format.format(Calendar.getInstance().getTime())).getTime(); | ||
| 389 | + } | ||
| 390 | + | ||
| 391 | + /** | ||
| 392 | + * 当前时间 如: 2013-04-22 10:37:00 | ||
| 393 | + */ | ||
| 394 | + @SuppressLint("SimpleDateFormat") | ||
| 395 | + public static String getCurrentDate() { | ||
| 396 | + format = new SimpleDateFormat("yyyy-MM-dd HH:mm"); | ||
| 397 | + return format.format(Calendar.getInstance().getTime()); | ||
| 398 | + } | ||
| 399 | + | ||
| 400 | + /** | ||
| 401 | + * 当前时间 如: 10:37 | ||
| 402 | + */ | ||
| 403 | + @SuppressLint("SimpleDateFormat") | ||
| 404 | + public static String getCurrentDateHHMM() { | ||
| 405 | + format = new SimpleDateFormat("HH:mm"); | ||
| 406 | + return format.format(Calendar.getInstance().getTime()); | ||
| 407 | + } | ||
| 408 | + | ||
| 409 | + /** | ||
| 410 | + * 当前时间 如: 10:37 | ||
| 411 | + * | ||
| 412 | + * @throws ParseException | ||
| 413 | + */ | ||
| 414 | + @SuppressLint("SimpleDateFormat") | ||
| 415 | + public static String getCurrentDateHHMMSS() { | ||
| 416 | + format = new SimpleDateFormat("HH:mm:ss"); | ||
| 417 | + return format.format(Calendar.getInstance().getTime()); | ||
| 418 | + } | ||
| 419 | + | ||
| 420 | + /** | ||
| 421 | + * 当前时间 如: 20130422 | ||
| 422 | + */ | ||
| 423 | + @SuppressLint("SimpleDateFormat") | ||
| 424 | + public static String getCurrentDateString() { | ||
| 425 | + format = new SimpleDateFormat("yyyyMMddHHmm"); | ||
| 426 | + return format.format(Calendar.getInstance().getTime()); | ||
| 427 | + } | ||
| 428 | + | ||
| 429 | + /** | ||
| 430 | + * 当前时间 如: 2013-04-22 | ||
| 431 | + */ | ||
| 432 | + @SuppressLint("SimpleDateFormat") | ||
| 433 | + public static String getCurrentTime() { | ||
| 434 | + format = new SimpleDateFormat("yyyy-MM-dd"); | ||
| 435 | + return format.format(Calendar.getInstance().getTime()); | ||
| 436 | + } | ||
| 437 | + | ||
| 438 | + @SuppressLint("SimpleDateFormat") | ||
| 439 | + public static String getSWAHDate() { | ||
| 440 | + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | ||
| 441 | + return format.format(Calendar.getInstance().getTime()); | ||
| 442 | + } | ||
| 443 | + | ||
| 444 | + @SuppressLint("SimpleDateFormat") | ||
| 445 | + public static Long stringToLongD(String param) throws ParseException { | ||
| 446 | + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); | ||
| 447 | + return format.parse(param.substring(0, param.length() - 4)).getTime(); | ||
| 448 | + } | ||
| 449 | + | ||
| 450 | + @SuppressLint("SimpleDateFormat") | ||
| 451 | + public static Long stringToLong(String param) throws ParseException { | ||
| 452 | + SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmm"); | ||
| 453 | + return format.parse(param).getTime(); | ||
| 454 | + } | ||
| 455 | + | ||
| 456 | + /** | ||
| 457 | + * 获取两个日期之间的间隔天数 | ||
| 458 | + * | ||
| 459 | + * @return | ||
| 460 | + */ | ||
| 461 | + @SuppressLint("SimpleDateFormat") | ||
| 462 | + public static int getGapCount(Date startDate, Date endDate) { | ||
| 463 | + Calendar fromCalendar = Calendar.getInstance(); | ||
| 464 | + fromCalendar.setTime(startDate); | ||
| 465 | + fromCalendar.set(Calendar.HOUR_OF_DAY, 0); | ||
| 466 | + fromCalendar.set(Calendar.MINUTE, 0); | ||
| 467 | + fromCalendar.set(Calendar.SECOND, 0); | ||
| 468 | + fromCalendar.set(Calendar.MILLISECOND, 0); | ||
| 469 | + | ||
| 470 | + Calendar toCalendar = Calendar.getInstance(); | ||
| 471 | + toCalendar.setTime(endDate); | ||
| 472 | + toCalendar.set(Calendar.HOUR_OF_DAY, 0); | ||
| 473 | + toCalendar.set(Calendar.MINUTE, 0); | ||
| 474 | + toCalendar.set(Calendar.SECOND, 0); | ||
| 475 | + toCalendar.set(Calendar.MILLISECOND, 0); | ||
| 476 | + | ||
| 477 | + return (int) ((toCalendar.getTime().getTime() - fromCalendar.getTime().getTime()) / (1000 * 60 * 60 * 24)); | ||
| 478 | + } | ||
| 479 | + | ||
| 480 | + /** | ||
| 481 | + * 日期转换成Java字符串 | ||
| 482 | + * | ||
| 483 | + * @param date | ||
| 484 | + * @return str | ||
| 485 | + */ | ||
| 486 | + @SuppressLint("SimpleDateFormat") | ||
| 487 | + public static String DateToStr(Date date) { | ||
| 488 | + | ||
| 489 | + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | ||
| 490 | + String str = format.format(date); | ||
| 491 | + return str; | ||
| 492 | + } | ||
| 493 | + | ||
| 494 | + /** | ||
| 495 | + * 字符串转换成日期 | ||
| 496 | + * | ||
| 497 | + * @param str | ||
| 498 | + * @return date | ||
| 499 | + */ | ||
| 500 | + @SuppressLint("SimpleDateFormat") | ||
| 501 | + public static Date StrToDate(String str) { | ||
| 502 | + | ||
| 503 | + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); | ||
| 504 | + Date date = null; | ||
| 505 | + try { | ||
| 506 | + date = format.parse(str); | ||
| 507 | + } catch (ParseException e) { | ||
| 508 | + e.printStackTrace(); | ||
| 509 | + } | ||
| 510 | + return date; | ||
| 511 | + } | ||
| 512 | + | ||
| 513 | + /** | ||
| 514 | + * 字符串转换成日期 | ||
| 515 | + * | ||
| 516 | + * @param str | ||
| 517 | + * @return date | ||
| 518 | + */ | ||
| 519 | + @SuppressLint("SimpleDateFormat") | ||
| 520 | + public static Date StrToDateDrop(String str) { | ||
| 521 | + | ||
| 522 | + SimpleDateFormat format = new SimpleDateFormat("yyyy.MM.dd"); | ||
| 523 | + Date date = null; | ||
| 524 | + try { | ||
| 525 | + date = format.parse(str); | ||
| 526 | + } catch (ParseException e) { | ||
| 527 | + e.printStackTrace(); | ||
| 528 | + } | ||
| 529 | + return date; | ||
| 530 | + } | ||
| 531 | + | ||
| 532 | + /** | ||
| 533 | + * @param time | ||
| 534 | + * @return | ||
| 535 | + */ | ||
| 536 | + @SuppressLint("SimpleDateFormat") | ||
| 537 | + public static long getLongTime(String time) { | ||
| 538 | + long ct = 0; | ||
| 539 | + try { | ||
| 540 | + format = new SimpleDateFormat("HH:mm:ss"); | ||
| 541 | + ct = format.parse(time).getTime(); | ||
| 542 | + } catch (Exception e) { | ||
| 543 | + e.printStackTrace(); | ||
| 544 | + } | ||
| 545 | + return ct; | ||
| 546 | + } | ||
| 547 | + | ||
| 548 | + /** | ||
| 549 | + * 判断两日期是否同一天 | ||
| 550 | + * | ||
| 551 | + * @param str1 | ||
| 552 | + * @param str2 | ||
| 553 | + * @return | ||
| 554 | + */ | ||
| 555 | + @SuppressLint("SimpleDateFormat") | ||
| 556 | + public static boolean isSameDay(String str1, String str2) { | ||
| 557 | + | ||
| 558 | + Date day1 = null, day2 = null; | ||
| 559 | + day1 = DateTimeUtil.strToDate(str1); | ||
| 560 | + day2 = DateTimeUtil.strToDate(str2); | ||
| 561 | + | ||
| 562 | + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); | ||
| 563 | + | ||
| 564 | + String ds1 = sdf.format(day1); | ||
| 565 | + | ||
| 566 | + String ds2 = sdf.format(day2); | ||
| 567 | + | ||
| 568 | + if (ds1.equals(ds2)) { | ||
| 569 | + return true; | ||
| 570 | + } else { | ||
| 571 | + return false; | ||
| 572 | + } | ||
| 573 | + | ||
| 574 | + } | ||
| 575 | + | ||
| 576 | + /** | ||
| 577 | + * 获取两个日期的时间差 | ||
| 578 | + */ | ||
| 579 | + @SuppressLint("SimpleDateFormat") | ||
| 580 | + public static int getTimeInterval(String date) { | ||
| 581 | + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | ||
| 582 | + int interval = 0; | ||
| 583 | + try { | ||
| 584 | + Date currentTime = new Date();// 获取现在的时间 | ||
| 585 | + Date beginTime = dateFormat.parse(date); | ||
| 586 | + interval = (int) ((beginTime.getTime() - currentTime.getTime()) / (1000));// 时间差 | ||
| 587 | + // 单位秒 | ||
| 588 | + } catch (ParseException e) { | ||
| 589 | + e.printStackTrace(); | ||
| 590 | + } | ||
| 591 | + return interval; | ||
| 592 | + } | ||
| 593 | + | ||
| 594 | + /** | ||
| 595 | + * 获取两个日期的时间差 yyyy.MM.dd HH.mm.ss | ||
| 596 | + */ | ||
| 597 | + @SuppressLint("SimpleDateFormat") | ||
| 598 | + public static int getInterval(String bDate, String eDate) { | ||
| 599 | + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy.MM.dd"); | ||
| 600 | + int interval = 0; | ||
| 601 | + try { | ||
| 602 | + Date currentTime = dateFormat.parse(eDate);// 获取现在的时间 | ||
| 603 | + Date beginTime = dateFormat.parse(bDate); | ||
| 604 | + interval = (int) ((beginTime.getTime() - currentTime.getTime()));// 时间差 | ||
| 605 | + // 单位秒 | ||
| 606 | + } catch (ParseException e) { | ||
| 607 | + e.printStackTrace(); | ||
| 608 | + } | ||
| 609 | + return interval; | ||
| 610 | + } | ||
| 611 | + | ||
| 612 | + /** | ||
| 613 | + * 两个时间之差 求出一个long Time | ||
| 614 | + * | ||
| 615 | + * @param date | ||
| 616 | + * @return | ||
| 617 | + */ | ||
| 618 | + @SuppressLint("SimpleDateFormat") | ||
| 619 | + public static long getTime(String date) { | ||
| 620 | + | ||
| 621 | + DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | ||
| 622 | + long diff = 0; | ||
| 623 | + try { | ||
| 624 | + Date currentTime = new Date();// 获取现在的时间 | ||
| 625 | + Date getdate = df.parse(date); | ||
| 626 | + diff = getdate.getTime() - currentTime.getTime(); | ||
| 627 | + | ||
| 628 | + } catch (Exception e) { | ||
| 629 | + } | ||
| 630 | + return diff; | ||
| 631 | + } | ||
| 632 | + | ||
| 633 | + | ||
| 634 | + /** | ||
| 635 | + * 日期转换成Java字符串 | ||
| 636 | + * | ||
| 637 | + * @param DATE1 | ||
| 638 | + * @param DATE2 | ||
| 639 | + * @return | ||
| 640 | + */ | ||
| 641 | + @SuppressLint("SimpleDateFormat") | ||
| 642 | + public static int compare_date(String DATE1, String DATE2) { | ||
| 643 | + DateFormat df = new SimpleDateFormat("yyyy-MM-dd"); | ||
| 644 | + try { | ||
| 645 | + Date dt1 = df.parse(DATE1); | ||
| 646 | + Date dt2 = df.parse(DATE2); | ||
| 647 | + if (dt1.getTime() >= dt2.getTime()) { | ||
| 648 | + return 1; | ||
| 649 | + } else if (dt1.getTime() < dt2.getTime()) { | ||
| 650 | + return -1; | ||
| 651 | + } else { | ||
| 652 | + return 0; | ||
| 653 | + } | ||
| 654 | + } catch (Exception exception) { | ||
| 655 | + exception.printStackTrace(); | ||
| 656 | + } | ||
| 657 | + return 0; | ||
| 658 | + } | ||
| 659 | + | ||
| 660 | + /** | ||
| 661 | + * 传入时间 算出星期几 | ||
| 662 | + * | ||
| 663 | + * @param str 2014年1月3日 | ||
| 664 | + * @param days 1:2014年1月4日 类推 | ||
| 665 | + * @return | ||
| 666 | + */ | ||
| 667 | + @SuppressLint("SimpleDateFormat") | ||
| 668 | + public static String formatDate(String str, int days) { | ||
| 669 | + | ||
| 670 | + String dateStr = ""; | ||
| 671 | + try { | ||
| 672 | + DateFormat df = DateFormat.getDateInstance(DateFormat.LONG); | ||
| 673 | + Date date = df.parse(str); | ||
| 674 | + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); | ||
| 675 | + Calendar c = Calendar.getInstance(); | ||
| 676 | + Date d = dateFormat.parse(dateFormat.format(date)); | ||
| 677 | + c.setTime(d); | ||
| 678 | + c.add(Calendar.DAY_OF_MONTH, days); | ||
| 679 | + switch (c.get(Calendar.DAY_OF_WEEK) - 1) { | ||
| 680 | + case 0: | ||
| 681 | + dateStr = "周日"; | ||
| 682 | + break; | ||
| 683 | + case 1: | ||
| 684 | + dateStr = "周一"; | ||
| 685 | + break; | ||
| 686 | + case 2: | ||
| 687 | + dateStr = "周二"; | ||
| 688 | + break; | ||
| 689 | + case 3: | ||
| 690 | + dateStr = "周三"; | ||
| 691 | + break; | ||
| 692 | + case 4: | ||
| 693 | + dateStr = "周四"; | ||
| 694 | + break; | ||
| 695 | + case 5: | ||
| 696 | + dateStr = "周五"; | ||
| 697 | + break; | ||
| 698 | + case 6: | ||
| 699 | + dateStr = "周六"; | ||
| 700 | + break; | ||
| 701 | + default: | ||
| 702 | + break; | ||
| 703 | + } | ||
| 704 | + } catch (Exception e) { | ||
| 705 | + e.printStackTrace(); | ||
| 706 | + } | ||
| 707 | + | ||
| 708 | + return dateStr; | ||
| 709 | + } | ||
| 710 | + | ||
| 711 | + /** | ||
| 712 | + * 根据提供的年月日获取该月份的第一天 | ||
| 713 | + */ | ||
| 714 | + public static String getSupportBeginDayofMonth(int year, int monthOfYear) { | ||
| 715 | + Calendar cal = Calendar.getInstance(); | ||
| 716 | + cal.set(Calendar.YEAR, year); | ||
| 717 | + cal.set(Calendar.MONTH, monthOfYear - 1); | ||
| 718 | + cal.set(Calendar.DAY_OF_MONTH, 1); | ||
| 719 | + cal.set(Calendar.HOUR_OF_DAY, 0); | ||
| 720 | + cal.set(Calendar.MINUTE, 0); | ||
| 721 | + cal.set(Calendar.SECOND, 0); | ||
| 722 | + | ||
| 723 | + cal.set(Calendar.DAY_OF_MONTH, 1); | ||
| 724 | + return cal.getTimeInMillis() + ""; | ||
| 725 | + } | ||
| 726 | + | ||
| 727 | + /** | ||
| 728 | + * 根据提供的年月获取该月份的最后一天 | ||
| 729 | + * | ||
| 730 | + * @return | ||
| 731 | + */ | ||
| 732 | + public static String getSupportEndDayofMonth(int year, int monthOfYear) { | ||
| 733 | + Calendar cal = Calendar.getInstance(); | ||
| 734 | + cal.set(Calendar.YEAR, year); | ||
| 735 | + cal.set(Calendar.MONTH, monthOfYear); | ||
| 736 | + cal.set(Calendar.DAY_OF_MONTH, 1); | ||
| 737 | + cal.set(Calendar.HOUR_OF_DAY, 23); | ||
| 738 | + cal.set(Calendar.MINUTE, 59); | ||
| 739 | + cal.set(Calendar.SECOND, 59); | ||
| 740 | + | ||
| 741 | + cal.add(Calendar.DAY_OF_MONTH, -1); | ||
| 742 | + return cal.getTimeInMillis() + ""; | ||
| 743 | + } | ||
| 744 | + | ||
| 745 | + public static String getYear(long millseconds) { | ||
| 746 | + | ||
| 747 | + SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss"); | ||
| 748 | + Date date = new Date(millseconds); | ||
| 749 | + return sdf.format(date).substring(0, 4); | ||
| 750 | + } | ||
| 751 | + | ||
| 752 | + public static String getMonth(long millseconds) { | ||
| 753 | + | ||
| 754 | + SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss"); | ||
| 755 | + Date date = new Date(millseconds); | ||
| 756 | + return sdf.format(date).substring(4, 6); | ||
| 757 | + } | ||
| 758 | + | ||
| 759 | + public static String formatFriendly(String timeStr) { | ||
| 760 | + String time = ""; | ||
| 761 | + try { | ||
| 762 | + time = DateTimeUtil.formatFriendly(new Date(Long.valueOf(timeStr) * 1000L)); | ||
| 763 | + } catch (Exception e) { | ||
| 764 | + Log.e("FriendCircleMessage", "Time format exception.", e); | ||
| 765 | + } | ||
| 766 | + return time; | ||
| 767 | + } | ||
| 768 | + | ||
| 769 | +} |
moudle_pedometer/src/main/res/layout/fragment_registration_info.xml
| @@ -20,6 +20,7 @@ | @@ -20,6 +20,7 @@ | ||
| 20 | android:layout_width="match_parent" | 20 | android:layout_width="match_parent" |
| 21 | android:layout_height="match_parent" | 21 | android:layout_height="match_parent" |
| 22 | android:layout_below="@id/topbar" | 22 | android:layout_below="@id/topbar" |
| 23 | + android:layout_marginTop="20dp" | ||
| 23 | android:orientation="vertical"> | 24 | android:orientation="vertical"> |
| 24 | 25 | ||
| 25 | <LinearLayout | 26 | <LinearLayout |
| @@ -67,6 +68,7 @@ | @@ -67,6 +68,7 @@ | ||
| 67 | android:padding="10dp"> | 68 | android:padding="10dp"> |
| 68 | 69 | ||
| 69 | <TextView | 70 | <TextView |
| 71 | + android:id="@+id/sex_text" | ||
| 70 | android:layout_width="wrap_content" | 72 | android:layout_width="wrap_content" |
| 71 | android:layout_height="wrap_content" | 73 | android:layout_height="wrap_content" |
| 72 | android:text="性别(非必填) 未选择" | 74 | android:text="性别(非必填) 未选择" |
| @@ -80,6 +82,7 @@ | @@ -80,6 +82,7 @@ | ||
| 80 | android:padding="10dp"> | 82 | android:padding="10dp"> |
| 81 | 83 | ||
| 82 | <TextView | 84 | <TextView |
| 85 | + android:id="@+id/birthday" | ||
| 83 | android:layout_width="wrap_content" | 86 | android:layout_width="wrap_content" |
| 84 | android:layout_height="wrap_content" | 87 | android:layout_height="wrap_content" |
| 85 | android:text="生日(非必填) 未选择" | 88 | android:text="生日(非必填) 未选择" |
| @@ -125,5 +128,6 @@ | @@ -125,5 +128,6 @@ | ||
| 125 | 128 | ||
| 126 | </LinearLayout> | 129 | </LinearLayout> |
| 127 | 130 | ||
| 131 | + | ||
| 128 | </RelativeLayout> | 132 | </RelativeLayout> |
| 129 | </layout> | 133 | </layout> |
moudle_pedometer/src/main/res/layout/wheel_view.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<android.support.constraint.ConstraintLayout | ||
| 3 | + xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 4 | + xmlns:tools="http://schemas.android.com/tools" | ||
| 5 | + android:layout_width="match_parent" | ||
| 6 | + android:layout_height="match_parent"> | ||
| 7 | + | ||
| 8 | + <com.cnlive.moudle.pedometer.utils.WheelView | ||
| 9 | + android:id="@+id/wheelview" | ||
| 10 | + android:layout_width="match_parent" | ||
| 11 | + android:layout_height="wrap_content" | ||
| 12 | + tools:ignore="MissingConstraints" /> | ||
| 13 | +</android.support.constraint.ConstraintLayout> | ||
| 0 | \ No newline at end of file | 14 | \ No newline at end of file |