我试图解析格式的日期:
2013-09-17T05:15:27.947
这是我的代码
String MessageRecieptDate = messageReceiptDate.Replace("T", " ").Remove(messageReceiptDate.Length-4);
DateTime dt = new DateTime();
IFormatProvider culture = new CultureInfo("en-US");
dt = DateTime.ParseExact(MessageRecieptDate, "dd MMM", culture);
Run Code Online (Sandbox Code Playgroud)
但它每次都会给出一些格式异常.似乎我错过了一些基本的东西.
因为jvm管理String的字符串池,从中查找任何新的String赋值,类似地,我们可以开发任何其他对象或原语的池吗?
我尝试了很多例子,但没有人工作.我尝试这个但是不行.
我也试过用tryLock().它总是返回false.为什么?
private boolean checkCompleteFile(File f)
{
RandomAccessFile file = null;
FileLock fileLock = null;
try
{
file = new RandomAccessFile(f, "rw");
FileChannel fileChannel = file.getChannel();
fileLock = fileChannel.lock();
if (fileLock != null)
{
fileLock.release();
file.close();
return false;
}
}
catch(Exception e)
{
return false;
}
return true;
}
Run Code Online (Sandbox Code Playgroud) 比如,我想在本机脚本中显示10种语言的列表,如果手机不支持该字体,它将回退到英文脚本.有什么方法可以检测特定设备支持哪些字体?换句话说,我只想检查"旁遮普"是否可以显示为"ਪੰਜਾਬੀ"
我知道这是一个非常新手的问题,但没有任何东西进入我的脑海.目前我正在尝试这一点,但对于这么大的数字来说,这是效率最低的方式.帮帮我.
int count = 66000000;
LinkedList<Integer> list = new LinkedList<Integer>();
for (int i=1;i<=count;i++){
list.add(i);
//System.out.println(i);
}
Run Code Online (Sandbox Code Playgroud)
编辑:
实际上我已经对整个列表(队列)重复执行操作(比如在一个条件下删除一些元素并再次添加),所以不得不迭代整个列表变得如此慢,用这样的数字花了超过10分钟.
我想知道用户的电话号码,但我在本文档中找不到任何提及.
有没有办法获取用户的电话号码?
我想将我的应用程序的默认字体更改为自定义字体.我能够为组件更改它,但有什么办法可以将任何fontfamily设置为所有组件的默认值?
我正在开发一款工作正常,直到2天.但是今天我又开始了,它还没有开始.当我启动It时,它会在启动后立即退出.自上次发布以来,我的代码中没有任何变化.我没有看到关于它的指针.没有任何例外或其他任何事情.我最近的更改包括更改应用图标和包名称.但是在这些变化之后我运行了应用程序.不知道什么是错的?
这是我唯一能提供的:
> 'TaskHost.exe' (CLR C:\windows\system32\coreclr.dll: DefaultDomain):
> Loaded 'C:\windows\system32\mscorlib.ni.dll'. Skipped loading symbols.
> Module is optimized and the debugger option 'Just My Code' is enabled.
> 'TaskHost.exe' (CLR C:\windows\system32\coreclr.dll: Silverlight
> AppDomain): Loaded
> 'C:\windows\system32\System.Windows.RuntimeHost.ni.dll'. Skipped
> loading symbols. Module is optimized and the debugger option 'Just My
> Code' is enabled. 'TaskHost.exe' (CLR C:\windows\system32\coreclr.dll:
> Silverlight AppDomain): Loaded
> 'C:\windows\system32\System.Windows.ni.dll'. Skipped loading symbols.
> Module is optimized and the debugger option 'Just My Code' is enabled.
> 'TaskHost.exe' …Run Code Online (Sandbox Code Playgroud) 我在任何地方都找不到任何工作,而且代码似乎与你在applet中的方式不同,我已经习惯了.我是新手.我怎样才能在我的JButtons中添加一个ActionListener(就是它?还是我在寻找其他东西?)?(我不确定是什么原因导致该code块变得如此不可思议,我无法解决它.)
`
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Main implements ActionListener{
static String answerOne = "";
static String answerTwo = "";
static boolean answerable = false;
static int labelX = 240, labelY = 48;
static int questionWrite = 0;
static String text = "Welcome! I will ask simple, two-answer questions, and you will answer them. Simple as that. ";
static int charIndex = 0;
private static void createAndShowGUI() {
JFrame frame = new JFrame("FrameDemo");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JLabel …Run Code Online (Sandbox Code Playgroud) 我试图运行此查询,但它给了我例外.
"至少有一个对象必须实现IComparable."
我不想通过我的自定义对象来命令/区分,而只是通过字符串(v.Venue).但是,使用自定义对象(而不是字符串)的类似查询(未实现IComparable)工作正常.
这是我的查询:
new ObservableCollection<KeyValuePair<int, string>>(
EventsList.Where(p => !string.IsNullOrEmpty(p.Venue))
.Distinct()
.OrderBy(i => i)
.Select((v, index) => new KeyValuePair<int, String>(index, v.Venue))
);
Run Code Online (Sandbox Code Playgroud)
EventsList 是一个 ObservableCollection<EventSchedules>
此外,我尝试将整个查询分成几部分,但它只对最后一个查询失败:
Select((v, index) => new KeyValuePair<int, String>(index, v.Venue))