reactjs - Datepicker date discrepancies between selected value, API, and value in DB - Stack Overflow

This is a situation that is completely perplexing to me.I am stuck using Material-UI core and not cur

This is a situation that is completely perplexing to me. I am stuck using Material-UI core and not currently allowed to upgrade to MUI X due possible vulnerabilities and my project lead not wanting me to add any new dependencies that could cause issues. So in MUI core, I created a datepicker as such:

Datepicker Component:

import * as React from 'react';
import { TextField } from '@material-ui/core';


function InputDatePicker(props) {
    const { error = null, label, name, onChange, value, ...other } = props;

    return (
         <TextField
            variant='outlined'
            label={label}
            name={name}
            value={(value === undefined || value === null) ? '' : value} 
            onChange={onChange}
            {...other}
            {...(error && {error: true, helperText: error})}
        />
    );
}

export default DatePicker;

to which I call to the component inside the app as such:

  <DatePicker
    type='date'
    onChange={handleInputChange}
    name='rescheduleDate'
    label='Reschedule Date'
    value={rescheduleDate}
   />

The confusing part happens once I attempt to use the datepicker. Let's say I selected March 31, 2025 from the datepicker. I am console logging the selected values in the from, which display as 2025-03-31. This makes sense because the picker requires a YYYY-MM-DD date format. I am info logging the values inside the Java code of my API which is showing Sun Mar 30 19:00:00 CDT 2025, which is the previous day. The time is always 19:00:00. When I check the date value inside our Oracle database, the date is displaying as 30-MAR-25 which matches the Java info log, but not the originally selected date value. To further make things confusing, when I call to the date value to display it inside the app, it is returning a date value of 2025-03-31T00:00:00.000+00:00, which matches the selected date, but not what is logged in the Java code or displayed in the database. I have read that this display discrepancy is caused by a time zone issue, but I don't know how to correct this inside the component. There is documentation for how to handle this in MUI X, but it does not work for MUI Core.

Is there something I can do to keep the date consistently displaying the same date (March 31). Since it seems to return the result to the app that is expected, I am tempted to just ignore it, but I am afraid that if we pull reports from the database it will be showing an incorrect date.

This is a situation that is completely perplexing to me. I am stuck using Material-UI core and not currently allowed to upgrade to MUI X due possible vulnerabilities and my project lead not wanting me to add any new dependencies that could cause issues. So in MUI core, I created a datepicker as such:

Datepicker Component:

import * as React from 'react';
import { TextField } from '@material-ui/core';


function InputDatePicker(props) {
    const { error = null, label, name, onChange, value, ...other } = props;

    return (
         <TextField
            variant='outlined'
            label={label}
            name={name}
            value={(value === undefined || value === null) ? '' : value} 
            onChange={onChange}
            {...other}
            {...(error && {error: true, helperText: error})}
        />
    );
}

export default DatePicker;

to which I call to the component inside the app as such:

  <DatePicker
    type='date'
    onChange={handleInputChange}
    name='rescheduleDate'
    label='Reschedule Date'
    value={rescheduleDate}
   />

The confusing part happens once I attempt to use the datepicker. Let's say I selected March 31, 2025 from the datepicker. I am console logging the selected values in the from, which display as 2025-03-31. This makes sense because the picker requires a YYYY-MM-DD date format. I am info logging the values inside the Java code of my API which is showing Sun Mar 30 19:00:00 CDT 2025, which is the previous day. The time is always 19:00:00. When I check the date value inside our Oracle database, the date is displaying as 30-MAR-25 which matches the Java info log, but not the originally selected date value. To further make things confusing, when I call to the date value to display it inside the app, it is returning a date value of 2025-03-31T00:00:00.000+00:00, which matches the selected date, but not what is logged in the Java code or displayed in the database. I have read that this display discrepancy is caused by a time zone issue, but I don't know how to correct this inside the component. There is documentation for how to handle this in MUI X, but it does not work for MUI Core.

Is there something I can do to keep the date consistently displaying the same date (March 31). Since it seems to return the result to the app that is expected, I am tempted to just ignore it, but I am afraid that if we pull reports from the database it will be showing an incorrect date.

Share Improve this question edited Mar 21 at 18:32 Olivier Tassinari 8,6916 gold badges25 silver badges28 bronze badges asked Mar 13 at 14:33 MtullisMtullis 611 silver badge6 bronze badges 2
  • Currently I am not adding any date formatting or time zone adjustment within the backend Java code. – Mtullis Commented Mar 13 at 15:25
  • I found a way of handling the situation inside the Java code, I just adjusted the timestamp from GTM as such Date newRescheduleDate = new Date(escheduleDate.getTime() + TimeZone.getTimeZone("GMT+5:00").getRawOffset()); Now The DB is diplaying the correct date. – Mtullis Commented Mar 13 at 17:27
Add a comment  | 

1 Answer 1

Reset to default 0

Check your server's timezone. Also, it could be from the formatting you're doing at the backend. Check the date formatting style you're using in your java code to make sure it's not formatting based on a specific time and timezone.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744695654a4588475.html

相关推荐

  • Windows下的python安装教程_2024年10月最新最详细的安装指南

    文章目录 前言一、下载python二、安装python三、验证环境四、配置环境变量&#xff08;可选&#xff09;总结 前言 Python 是一种广泛使用的高级编程语言&#xff0c;以其简洁易读的语法和强大的

    1小时前
    00
  • 方法分享

    作者,Evil Genius现在的日子,关税在涨,物价在涨,钱是越来越难挣了。什么东西在跌呢?工资在跌,房价也跌,房租反而涨了,生活的压力感觉越来越大了。对于生信分析而言,什么东西是最重要的?尤其是空间转录组的分析?很显然,硬件是服务器,软

    1小时前
    00
  • VMware虚拟机设置为固定IP

    操作原因:安装完成虚拟机后会生成一个IP,由于ip变化导致搭建好的k8s集群无法启动。因此将虚拟机配置为固定IP1、修改虚拟网络编辑器:打开虚拟网络编辑器,修改NAT设置:2、修改电脑的虚拟网卡地址选中这个网卡-->点击右键-->

    1小时前
    00
  • Python 爬虫如何伪装 Referer?从随机生成到动态匹配

    一、Referer 的作用与重要性Referer 是 HTTP 请求头中的一个字段,用于标识请求的来源页面。它在网站的正常运行中扮演着重要角色,例如用于统计流量来源、防止恶意链接等。然而,对于爬虫来说,Referer 也可能成为被识别为爬虫

    1小时前
    00
  • Power BI Vega 条形纵向折线组合图表

    条形图和纵向折线图组合常用来展示绝对值和率值的组合。之前在知识星球分享过SVG的版本(使用内置表格加载),今天换一种实现方式,使用Deneb视觉对象:把需要展示的维度和指标拖拽到Deneb,本例维度为城市,绝对值为[kpi]度量值,率值为[

    55分钟前
    00
  • DeepSeek辅助Power BI自定义Vega条形图

    Power BI Deneb这个视觉对象支持Vega自定义图表。网上有丰富的Vega代码资源,参考《Power BI Deneb图表资源库》,EasyShu提供了Excel版本的Vega图表库,Power BI也可以借鉴。使用Vega并不意

    53分钟前
    00
  • 完美解决win7系统使用wireshark未响应问题

    Win7系统&#xff0c;安装wireshark4.0的版本&#xff0c;发现打开可以打开&#xff0c;但是只要点击网卡之后就会显示无响应 一开始我以为是位数的原因&#xff0c;之前用的64位的&am

    53分钟前
    00
  • windows7删除正在计算机,win7系统删除文件提示“正在准备再循环”的解决教程

    有时候可能会遇到win7系统删除文件提示“正在准备再循环”的问题&#xff0c;如果我们遇到了win7系统删除文件提示“正在准备再循环”的问题&#xff0c;要怎么处理win7系统删除文件提示“正在准备再循环”呢&#

    50分钟前
    00
  • 苹果电脑装win7系统问题

    安装中问题&#xff1a; Windows 未能启动。原因可能是最近更改了硬件或软件。解决此问题的步骤&#xff1a; 1. 插入Windows 安装光盘并重新启动计算机。 2. 选择语言设置&#xff0c;然后单击

    48分钟前
    00
  • 瞧瞧别人家的日期处理,那叫一个优雅!

    前言在我们的日常工作中,需要经常处理各种格式,各种类似的的日期或者时间。比如:2025-04-21、20250421、2025年04月21日等等。有些字段是String类型,有些是Date类型,有些是Long类型。如果不同的数据类型,经

    46分钟前
    00
  • 在win7系统电脑安装node16的版本(已成功安装运行)

    很多银行的项目行方都要求内网开发&#xff0c;但是我遇到的几个银行基本都是win7系统的电脑&#xff0c;而前端的项目又是需要高版本的node才能跑起来&#xff0c;所有就记录此解决方案文章&#xff0

    44分钟前
    00
  • 铜缆以太网19

    40G-CR4100G-CR10 (C85)PCS (C82)(二)发送方向发送过程发送过程基于从XLGMIICGMII接收到的TXD<63:0>和TXC<7:0>信号生成块。1个XLGMIICGMII数据发送

    41分钟前
    00
  • 计算机无法查看图片,Win7系统提示&quot;windows照片查看器无法打开此图片&quot;的解决方法...

    Win7系统经常会用Windows照片查看器查看图片&#xff0c;但是有位用户查看图片的时候出现提示“windows照片查看器无法打开此图片”,为什么会出现这样的问题呢&#xff1f;这是因为此文件可能已损坏、损毁或过大。

    38分钟前
    00
  • 飞书多维表格批量转换

    之前一直以为,飞书多维表格是专门用来协作的,除了漂亮一点也没啥。近期偶然得知飞书多维表格已经新增了 AI 的加持,变得不得了了,今天就来分享一个场景:不同数据库 SQL 格式的批量转换。假设你现在有一批 Oracle 脚本,现在因为某种原因

    38分钟前
    00
  • Sentinel 的熔断和限流

    在分布式系统里,服务之间牵一发而动全身,一个接口雪崩,可能带崩整个应用链路。要想系统抗住流量洪峰,顶住突发异常,就得在稳定性上下功夫。今天我就来说说稳定性保障里的老将——Sentinel,看看它是怎么凭借限流熔断,在服务治理的江湖里占得一席

    33分钟前
    00
  • MTVInpaint:多任务视频修复框架,以双分支注意力与两阶段流水线统一完成、插入任务,处理长视频 !

    视频修复涉及在视频中修改局部区域,确保空间和时间上的一致性。现有的大多数方法主要集中在场景完成(即填补缺失区域)上,并缺乏以可控方式在场景中插入新目标的能力。幸运的是,最近在文本到视频(T2V)扩散模型方面的进展为文本指导的视频修复铺平了

    28分钟前
    20
  • Oracle中删除的列数据可以进行恢复么?

    有朋友提出闪回可以恢复删除的列(包括数据),这个可行么?实践是检验真理的唯一标准,创建一张测试表,代码语言:javascript代码运行次数:0运行复制CREATE TABLE t_flash_01 (id NUMBER, c1 varch

    26分钟前
    20
  • 得物增长兑换商城的构架演进

    一、简介在移动互联网蓬勃发展的今天,用户的选择日益多元化,App市场的竞争也愈发白热化。为了在激烈的市场竞争中脱颖而出,提升用户获取效率并增强用户粘性,越来越多的应用开始采用积分兑换、抽奖等互动玩法。这些精心设计的运营策略不仅能够满足用户的

    21分钟前
    20
  • win10系统缓存在哪win10系统缓存在哪看这里

    在 Windows 10 系统中&#xff0c;缓存被存储在多个不同的位置&#xff0c;了解这些位置对于优化系统性能和管理磁盘空间至关重要。 一、临时文件缓存 按下“WindowsR”组合键&#xff0c;输入

    21分钟前
    20
  • OFC 2025 Google报告:AI时代的光通信挑战

    在OFC会议的数据中心峰会上,谷歌带来了一场深度分享,直指AI和ML时代光通信技术面临的关键问题。报告中,谷歌明确指出可靠性与可用性、功耗、带宽规模三大“潜在砖墙”,并结合实际案例与数据,剖析挑战本质及解决思路 。一、AI时代的

    13分钟前
    00

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信