我已将我的数据库导出到CSV文件,时间戳现在如下所示:
1384204028
例如,如何将其转换为典型格式2013-01-19 03:14:07?
我有一个字符串,表示法语区域的日期:09-oct-08:
我需要解析那个String,所以我想出了这个SimpleDateFormat:
String format2 = "dd-MMM-yy";
Run Code Online (Sandbox Code Playgroud)
但是我对月份部分有一个问题,似乎预计会有一个结束点:
df2.format(new Date());
Run Code Online (Sandbox Code Playgroud)
给我 :
28-oct.-09
Run Code Online (Sandbox Code Playgroud)
现在什么是让我理解SimpleDateFormat("09-oct-08")的最好方法?
完整代码:
String format2 = "dd-MMM-yy";
DateFormat df2 = new SimpleDateFormat(format2,Locale.FRENCH);
date = df2.parse("09-oct-08");
Run Code Online (Sandbox Code Playgroud)
这给了我:java.text.ParseException:Unparseable date:"09-oct-08"
如果我然后尝试记录:
df2.format(new Date());
Run Code Online (Sandbox Code Playgroud)
我明白了:28-oct.-09
当我用C#写日期时
DateTime.Now.ToString("yyyy/MM/dd")
Run Code Online (Sandbox Code Playgroud)
然后它返回2010-09-10,但我需要2010/09/10.如何使其输出斜线?
我们知道dateformat类不是线程安全的.我有一个多线程场景,需要使用dateformats.我无法在新线程中创建新实例,因为SimpledateFormat创建似乎很昂贵(构造函数最终调用"编译",这是昂贵的).经过一些测试,我只剩下两个选项:
有什么建议?
如果大家之前已经面对过这个问题,你会采取什么方向.
我有一个jstl循环,我想格式化表单的日期:输入.我已经尝试了许多我喜欢在线的建议的排列,但是我无法让它工作..有人可以看一下吗?
我已经为上下文包含了完整的循环,但问题出在最后一个<td></td>块中.
<c:forEach items="${valueTransactionsModel.transactions}" var="transaction" varStatus="loopStatus">
<tr class="${loopStatus.index % 2 == 0 ? 'even' : 'odd'}">
<spring:message code="valueTransactions.transactionType" var="transactionTypeLbl" />
<tags:dropdown id="transactionTypeId${loopStatus.index}" path="transactions['${loopStatus.index}'].valueTransactionType.id"
fieldName="${transactionTypeLbl}" classStyle="mandatory" items="${transactionTypes}" itemLabel="value"/>
</tr>
<tr class="${loopStatus.index % 2 == 0 ? 'even' : 'odd'}">
<spring:message code="valueTransactions.transactionAmount" var="valueTransactionAmountLbl${loopStatus.index}" />
<tags:input id="transactionAmountId${loopStatus.index}"
path="transactions['${loopStatus.index}'].valueTransactionAmount"
fieldName="valueTransactionAmountLbl${loopStatus.index}"
maxlength="30" classStyle="mandatory" />
<spring:message code="valueTransactions.transactionDate"
var="valueTransactionDateLbl${loopStatus.index}" />
<td>
<form:input type="text" path="transactions['${loopStatus.index}'].valueTransactionDate" cssClass="mandatory" value="<fmt:formatDate value="transactions['${loopStatus.index}'].valueTransactionDate" type="date" pattern="yyyy-MM-dd"/>" />
</td>
</tr>
</c:forEach>
Run Code Online (Sandbox Code Playgroud)
我最近的问题是:
JSPG0055E:无法从name [transactions [] value [$ {loopStatus.index}]创建xml属性
我不需要整个故事来澄清我的问题,所以我只是展示代码(这只是一个例子).为什么我的结果有所不同?
码
long millis = 2305293L;
System.out.println(
millis + "ms = " +
(millis / 1000) + "s = " +
(millis / 1000 / 60) + "m");
System.out.println(
new SimpleDateFormat("HH:mm:ss").
format(
new Date(millis)
)
);
Run Code Online (Sandbox Code Playgroud)
产量
2305293ms = 2305s = 38m
01:38:25
Run Code Online (Sandbox Code Playgroud) 昨天尝试读取CSV时,我注意到PowerShell在使用时似乎总是采用美国日期格式[datetime]"date".
我的区域设置都是正确的,并[DateTime]::Parse("date")使用英国日期格式(年/月/ 日).
这是一个错误,还是一个刻意的决定?如果是故意的决定,是否记录在任何地方?
PS D:\> [DateTime]"12/10/2012"
10 December 2012 00:00:00
PS D:\> [DateTime]::Parse("12/10/2012")
12 October 2012 00:00:00
Run Code Online (Sandbox Code Playgroud)
(注意:在美国的机器上,我希望这些物体是相同的,但在英国的机器上却不是这样).
注意:我不想更改格式(它是来自外部源的文件),我不想在输出中格式化日期,我知道我可以使用[DateTime]::Parse().问题是结尾的一点?:-)
我一直在StackOverflow Android中获取当前UTC时间, 并且 如何在Java中获取UTC或GMT中的当前日期和时间?
我尝试了两种方法来获取GMT手机的当前时间.我在西班牙,区别是GMT + 2.让我们看一个例子:1º尝试:我创建了一个格式并将其应用于System.currentTimeMillis();
DateFormat dfgmt = new java.text.SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
dfgmt.setTimeZone(TimeZone.getTimeZone("GMT"));
String gmtTime = dfgmt.format(new Date());
//Using System.currentTimeMillis() is the same as new Date()
Date dPhoneTime = dfgmt.parse(gmtTime);
Long phoneTimeUTC = dPhoneTime.getTime();
Run Code Online (Sandbox Code Playgroud)
我需要将那个时间减去另一个时间,这就是为什么我将演员阵容变为Long.
DateFormat df = new java.text.SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
Date arrivalDate = df.parse(item.getArrivalDate());
//the String comes from JSON and is for example:"UTC_arrival":"2011-05-16 18:00:00"
//which already is in UTC format. So the DateFormat doesnt have the GMT paramater as dfgmt
diff = arrival.getTime() - phoneTimeUTC ;
Run Code Online (Sandbox Code Playgroud)
我也试过这个:
Calendar …Run Code Online (Sandbox Code Playgroud) 试图将L10N实现理解为Django,这是我的设置
LANGUAGE_CODE = 'fr-FR'
USE_L10N = True
Run Code Online (Sandbox Code Playgroud)
如果我试试
>>> datetime.datetime.strptime('2012-05-30 15:30', '%Y-%m-%d %H:%M')
.strftime('%c')
Run Code Online (Sandbox Code Playgroud)
它会给我'Wed May 30 15:30:00 2012'这是EN语言环境.然而,医生说:
[...]访问相同内容但使用不同语言的两个用户将看到以不同方式格式化的日期和数字字段,具体取决于其当前区域设置的格式[...]
他们在谈论为各自的浏览器设置的区域设置吗?
如果没有,我怎么能默认将它设置为法语?
我有一个像这样的格式的日期fecha2.value = '2014-01-06',但我想'01-06-14'使用jQuery 将格式更改为this .
我怎样才能做到这一点?提前致谢.
date-format ×10
date ×3
java ×3
localization ×2
android ×1
c# ×1
clone ×1
django ×1
gmt ×1
javascript ×1
jquery ×1
jsp ×1
jstl ×1
locale ×1
mysql ×1
powershell ×1
python ×1
spring-mvc ×1
sql ×1
timestamp ×1