我正在使用SimpleDateFormat来显示这样的日历:
public String getDate()
{
String DATE_FORMAT = "EEEE, dd/MM/yyyy HH:mm:ss";
SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
System.err.println(date.getTime().getMonth());
return sdf.format(date.getTime());
}
Run Code Online (Sandbox Code Playgroud)
shell返回6并显示:mardi, 06/07/2010 12:44:52
这不可能吗?为什么?
谢谢
在我的Rails应用程序中,我遍历一个数组以创建必须由OR连接的条件列表.以下是我目前这样做的基本流程.
conditions = nil
set.each do |value|
condition = value.to_condition
conditions = conditions ? conditions.or(condition) : condition
end
Run Code Online (Sandbox Code Playgroud)
显然,它并不漂亮,但我仍然不完全了解Arel的方式.它是否提供了更好的OR加入一组动态生成条件的方法?
我使用了常见的模拟代码,它工作得很好,直到我在域中插入随机的'dggdgsdg' - 然而它仍然有效...
if (LogonUser(Username, Domain, Password, Logon32LogonInteractive, Logon32ProviderDefault, ref existingTokenHandle) &&
DuplicateToken(existingTokenHandle, (int)SecurityImpersonationLevel.SecurityDelegation, ref duplicateTokenHandle))
{
Identity = new WindowsIdentity(duplicateTokenHandle);
ImpersonationContext = Identity.Impersonate();
}
else
{
throw new Win32Exception(Marshal.GetLastWin32Error());
}
Run Code Online (Sandbox Code Playgroud)
我在我的域上使用了一些TestUser,但它确实有效.我然后切换域,随意废话'werwerhrg',它冒充我的域名上的TestUser!为什么?我会期待抛出异常,为什么它在起作用?
private const int Logon32LogonInteractive = 2;
private const int Logon32ProviderDefault = 0;
public enum SecurityImpersonationLevel
{
SecurityAnonymous = 0,
SecurityIdentification = 1,
SecurityImpersonation = 2,
SecurityDelegation = 3
}
[DllImport("advapi32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
private static extern bool LogonUser(String lpszUsername, String lpszDomain, String lpszPassword, int dwLogonType, …Run Code Online (Sandbox Code Playgroud) 假设我在视图中看到这样的字段:
<li class="bigfield">
<?php echo $form->input('phone', array(
'placeholder' => 'Phone',
'label' => false,
'between' => '<br />'
)); ?>
</li>
Run Code Online (Sandbox Code Playgroud)
如果我在此字段上有验证规则并且验证失败,我会看到以下HTML:
<li class="bigfield">
<div class="input text required error">
<br>
<input name="data[Appointment][email]" type="text" placeholder="Email"
maxlength="45" value="" id="AppointmentEmail" class="form-error">
<div class="error-message">Please enter a valid email address</div>
</div>
</li>
Run Code Online (Sandbox Code Playgroud)
我很喜欢做这样的事情的错误消息的div移动到页面的整个不同的组成部分,而然后用相同<LI>与字段本身里面有它.这样做最直接的方法是什么?
只是好奇当你发布到Facebook的链接时,他们似乎解析了一些图像和一些关于该链接的文本.有没有人猜测他们如何确定要显示的文字和图像?
我在创建查询时遇到了一些问题,该查询给出了总和的平均值.我在stackoverflow中阅读了一些示例,但无法做到.任何人都可以帮我理解如何做到这一点吗?这是我的数据:
Transaction_x0020_Number Product_x0020_Code Sales_x0020_Value Date Cashier
000356 350 24.99 2010-06-04 131
000356 726 32.99 2010-06-04 131
000357 350 24.99 2010-06-04 131
000358 350 24.99 2010-06-04 131
000358 360 24.99 2010-06-04 131
000770 703 69.99 2010-06-04 130
000771 726 32.99 2010-06-04 130
000772 1126 5 2010-06-04 130
000773 482 32.99 2010-06-04 130
000774 600 32.99 2010-06-04 130
000775 350 24.99 2010-06-04 130
Run Code Online (Sandbox Code Playgroud)
基本上我需要收银员的平均交易价值.我无法运行基本avg,因为它将占用所有行,但每个事务可以有多行.最后我想要:
Cashier| Average|
131 | 44.31 |(Which comes from the sum divided by 3 transactions not 5 rows)
130 …Run Code Online (Sandbox Code Playgroud) 我想知道是否有人对我即将开始的事情有任何经验.我有几个csv文件大小都在GB左右,我需要将它们加载到oracle数据库中.虽然我加载后的大多数工作都是只读的,但我还是需要不时加载更新.基本上我只需要一个很好的工具来一次加载几行数据直到我的数据库.
这是我到目前为止所发现的:
我可以使用SQL Loader做很多工作
我可以使用批量插入命令
某种批量插入.
以某种方式使用预备语句可能是个好主意.我想我想知道每个人都认为这是完成插入的最快方法.有小费吗?
我已经读过一个变量永远不应该做多件事.重载变量以执行多个操作是不好的.
因此,我最终编写如下代码:(使用customerFound变量)
bool customerFound = false;
Customer foundCustomer = null;
if (currentCustomer.IsLoaded)
{
if (customerIDToFind = currentCustomer.ID)
{
foundCustomer = currentCustomer;
customerFound = true;
}
}
else
{
foreach (Customer customer in allCustomers)
{
if (customerIDToFind = customer.ID)
{
foundCustomer = customer;
customerFound = true;
}
}
}
if (customerFound)
{
// Do something
}
Run Code Online (Sandbox Code Playgroud)
但在内心深处,我有时想写这样的代码:(没有customerFound变量)
Customer foundCustomer = null;
if (currentCustomer.IsLoaded)
{
if (customerIDToFind = currentCustomer.ID)
{
foundCustomer = currentCustomer;
}
}
else
{
foreach …Run Code Online (Sandbox Code Playgroud) 我正在改变我的JPA代码以利用线程.我为每个线程都有一个单独的实体管理器和事务.
我曾经拥有(针对单线程环境)的代码如下:
// get object from the entity manager
X x = getObjectX(jpaQuery);
if(x == null)
{
x = new X();
x.setVariable(foo);
entityManager.persist(x);
}
Run Code Online (Sandbox Code Playgroud)
使用多线程环境中的代码我得到重复键,因为我认为,getObjectX为一个线程返回null,然后该线程被换出,下一个线程调用getObjextX,也变为null,然后两个线程将创建并持久化一个新的X().
如果没有同步添加,是否有一种原子方法来获取/保存 - 如果不存在JPA的值或者我应该重新考虑我的方法
编辑:
我正在使用最新的Eclipselink和MySql 5.1
编辑2:
我添加了同步... MASSIVE性能命中(到了无法使用的程度).要在主线程上收集所有数据,然后在该线程上进行创建.
c# ×3
java ×2
.net ×1
arel ×1
bulkinsert ×1
cakephp ×1
date ×1
facebook ×1
formatting ×1
identity ×1
insert ×1
jpa ×1
mysql ×1
oracle ×1
sql ×1
sql-loader ×1
subquery ×1
validation ×1