我有字符串日期:
"01/15/2015 12:00 AM"
Run Code Online (Sandbox Code Playgroud)
我希望"dd/MM/yyyy' 'HH:mm:ss"格式化一个日期对象.我怎样才能做到这一点?
我试过了:
String datetime1 ="01/15/2015 12:00 AM"
DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm a");
Date datepicker1 = dateFormat.parse(datetime1);
Run Code Online (Sandbox Code Playgroud)
但这datepicker是2016年的约会.我不知道为什么会这样.
我认为这个问题在标题中,
我已经尝试过匹配器和模式,这个正则表达式\\((.*?)\\)但它只是让我只是括号之间的字符串,没有*3,
我怎么能改变这个:(a+b)*3+7
对此:(aplusb)*3+7
我尝试替换所有,但它也取代了括号中的'+',我得到了这个,(aplusb)*3plus7
但我想替换它像我说的那样:(aplusb)*3+7
我在问之前尝试了很多方法,所以请帮助我帮助我,抱歉我的弱英语:)
一直在环顾四周,看看是否有什么可以帮助我,但我不太了解人们的回答,我所理解的任何事情似乎都无法解决问题!所以基本上就像标题所说,我得到一个数组索引超出范围的异常,我不明白为什么.任何帮助是极大的赞赏.
码:
import javax.swing.*;
public class Array {
public static void main(String[] args) {
double height[] = new double[10];
String heightAsString;
int i, over18 = 0, under16 = 0;
for(i = 1; i <= height.length; i++){
heightAsString = JOptionPane.showInputDialog("Please Enter The Height Of Person " + i);
height[i] = Double.parseDouble(heightAsString);
if(height[i] > 1.8){
over18 += 1;
}
if(height[i] < 1.6){
under16 += 1;
}
}
JOptionPane.showMessageDialog(null,"The Total Number Of People Over 1.8m Is: " + over18 +
"\nThe Total Number …Run Code Online (Sandbox Code Playgroud) regexp = re.compile('[A-Z]\\d{4}')
prefix = regexp.match("\"O1533_FOO\" INTEGER NOT NULL ,")
Run Code Online (Sandbox Code Playgroud)
前缀是无,但我预计它是"O1533".
当我使用基于Web的工具http://regexr.com/时,它可以工作.
我试图\用不同数量的\s 逃脱,我也尝试划分/s.无法让它工作.
一些RegExp专家可以修复我的表达吗?
我需要帮助,我只是学习C,不知道出了什么问题:
我在这里调用set_opts函数:
char * tmploc ;
tmploc=set_opts("windir","\\temp.rte");
printf(tmploc);
Run Code Online (Sandbox Code Playgroud)
(我知道,printf没有格式化,只是用于测试目的)
功能看起来像这样:
char * set_opts(char * env,char * path){
char * opt;
opt=malloc(strlen(env)+strlen(path)+1);
strcpy(opt,getenv(env));
strcat(opt,path);
return opt;
}
Run Code Online (Sandbox Code Playgroud)
一切都很好,但是当我再试一次时:
char * tmploc2 ;
tmploc2=set_opts("windir","\\temp.rte");
printf(tmploc2);
Run Code Online (Sandbox Code Playgroud)
...程序刚刚终止
请告诉我我做错了什么
我试图应用一个补丁,它允许我使用std::to_string(). 我在 rm 上使用/usr/include/wchar.h,然后将wchar.h我下载的修补程序复制到 /usr/include 目录。现在,当我尝试编译程序时,它抱怨找不到_mingw.h
在这一点上,我只想找到一种方法来获取旧的副本wchar.h并替换“修补”的副本。我会找到一种方法来做到这一点std::to_string();
我做了这个小代码:
void *toto = malloc(8 * sizeof(char *) * 8);
char **tata = (char **)toto;
tata[5][5] = 'a'
Run Code Online (Sandbox Code Playgroud)
但我有一个分段错误.我怎样才能将我转换void *为char **?
void main()
{
int i,sample;
clrscr();
for(i=0;i<5;i++)
{
sample=rand();
printf("%d\n",sample);
}
getch();
}
Run Code Online (Sandbox Code Playgroud)
对于上述代码,每次执行时,都会生成相同的随机数346,130,10982,1090,11656.但是当我执行代码时,我需要生成不同的随机数.
谁能帮我?
将前4个字符与最后4个字符串交换的方式是什么?
例如,我有字符串20140613,我想将其转换为06132014.
输入:
val str="(2500 - Analytical Charge Percentage of Monitoring Structure (MS) type Sub-Business Unit (SSBU) : 803.130000000000000000)(388 - Monitoring Structure (MS) type Sub-Business Unit (SSBU) : JzCddaxT)"
Run Code Online (Sandbox Code Playgroud)
想要在 () 中使用两个更大的字符串作为数组的元素。在这种情况下,如果我们在 ")(" 上拆分:
预期输出:
arr(0) = "(2500 - Analytical Charge Percentage of Monitoring Structure (MS) type Sub-Business Unit (SSBU) : 803.130000000000000000"
arr(1) = "388 - Monitoring Structure (MS) type Sub-Business Unit (SSBU) : JzCddaxT)"
Run Code Online (Sandbox Code Playgroud)
我正在使用 str.split("[\\\\)\\\\(]")但它不起作用。