我有以下方法,我想更短或更快,如果没有别的.欢迎所有评论:
Bellow方法接受一个日期对象,形成它("EEE hh:mma MMM d,yyyy"),然后确定日期是今天还是昨天,如果是,则返回"(昨天|今天)hh:mma "格式化的字符串.
public static String formatToYesterdayOrToday(String date) {
SimpleDateFormat sdf = new SimpleDateFormat("EEE hh:mma MMM d, yyyy");
Date in = null;
try {
in = sdf.parse(date);
} catch (ParseException e) {
log.debug("Date parsing error:", e);
}
Calendar x = Calendar.getInstance();
x.setTime(in);
String hour = Integer.toString(x.get(Calendar.HOUR));
String minute = Integer.toString(x.get(Calendar.MINUTE));
String pm_am = x.get(Calendar.AM_PM) == Calendar.AM ? "AM" : "PM";
x.set(Calendar.HOUR, 0);
x.set(Calendar.HOUR_OF_DAY, 0);
x.set(Calendar.MINUTE, 0);
x.set(Calendar.SECOND, 0);
x.set(Calendar.MILLISECOND, 0);
Calendar today = Calendar.getInstance();
today.set(Calendar.HOUR, 0);
today.set(Calendar.HOUR_OF_DAY, …Run Code Online (Sandbox Code Playgroud) 我有这个问题.我需要做以下事情:
例如.今天日期是2012年1月12日19:00
我怎样才能创建一个新的日期,即2012年1月12日00:00(当天开始)
这似乎很容易,但我找不到任何groovyway得到它,任何帮助将是apreciated.
我在我的iPhone 5上安装了iOS 7,在我的Mac上安装了Xcode 5的Beta版本.
当我想在我的iPhone上运行应用程序时,Xcode说:
"没有配置的ios设备可用于兼容的iOS版本"
什么地方出了错?
我一直在尝试在Swift中使用Timer,我将它简化为以下内容:
func startTimer () {
timer = Timer.scheduledTimer(timeInterval: 0.1, target: self, selector: #selector(ViewController.test), userInfo: nil, repeats: true)
}
func test () {
print("FIRED")
}
Run Code Online (Sandbox Code Playgroud)
我想从另一个函数调用此函数并验证startTimer函数是否有效,但计时器不会触发.这与RunLoop有关吗?我对编码很新,所以任何解释都会受到赞赏.
我有一个数据库,在任何时间点都有数百个活动连接.当我使用DROP USER sql语句删除用户帐户时,需要约4秒,在此期间所有其他连接都具有"检查权限"状态.这意味着要删除1000个用户,我将有效地锁定数据库大约4000秒,这是不可接受的.但是,我注意到从mysql.users表中删除用户行是即时的.
从mysql.users kosher中删除一行?与使用DROP USER相比有哪些缺点?我在其他地方留下陈旧的行吗?有传播问题吗?我很可能不得不走这条路,但我想知道我还需要做些什么.
我正在Static Library为iOS应用程序创建一个.我几乎完成了它,但是资源存在问题.
我的静态库使用了大量的图像和声音文件.如何使用我的静态库传输它?
我知道我们可以将它包装在一个包上并沿着.a文件提供它.但我不知道如何将图像和声音文件包装在Bundle文件中.
我做了什么:
Settings Bundle.我为我的一个可可应用程序创建了自己的框架.我将该框架添加到我的项目中并从该框架调用了一个方法.当我试图运行我的应用程序时,它崩溃了:
崩溃日志:
dyld: Library not loaded: @rpath/MMP.framework/Versions/A/MMP
Referenced from: /Users/Midhun/Library/Developer/Xcode/DerivedData/MMPTest-ccvjtgedqkcftchapjehhwjbaqdq/Build/Products/Debug/MMPTest.app/Contents/MacOS/MMPTest
Reason: image not found
Run Code Online (Sandbox Code Playgroud)

Linking如:
FrameWorksProject的根目录下的文件夹中.Link Binary With LibrariesSection 下添加了框架
平台详情:
Xcode: 4.6.2
OS X : 10.8
Run Code Online (Sandbox Code Playgroud)
我尝试了什么(崩溃后)
otool.它显示了如下路径:
但我无法解决这个问题.请帮助我,提前谢谢.
我正在开发基于Android的BLE接近感应功能,需要一些信息.目前我看到没有针对Android的BLE信标制造商.到目前为止我找到了2个iPhone.1)http://www.estimote.com 2)http://www.gimbal.com
Estimote声称他们的设备是通用的,但主要是为iBeacons公开.所以我不确定是否应该为Android上的功能订购它们.其次,万向节明确提到他们的设备不会启用Android用于接近感应.
因此,如果你们中的任何人知道我在哪里可以订购与Android兼容的BLE信标,请告诉我.
另一件事,对于原型测试,我想知道我是否可以使用支持Android BLE的平板电脑或智能手机作为发出BLE信号的信标?到目前为止,android的文档仅建议如何检测信标,但我不确定Android设备是否可以用作信标.任何见解?
我正面临着EditText setError弹出位置的问题.
我正在使用以下代码来创建布局:
activity_profile.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" android:fitsSystemWindows="true"
tools:context=".ProfileActivity"
android:orientation="vertical">
<android.support.design.widget.AppBarLayout android:layout_height="wrap_content"
android:layout_width="match_parent" android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar android:id="@+id/toolbar"
android:layout_width="match_parent" android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary" app:popupTheme="@style/AppTheme.PopupOverlay" />
</android.support.design.widget.AppBarLayout>
<include layout="@layout/profile" />
</android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)
是profile.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context=".ProfileActivity"
tools:showIn="@layout/activity_profile">
<EditText
android:id="@+id/etProfileName"
android:layout_width="match_parent"
android:layout_height="50dp"
android:capitalize="words"
android:hint="@string/et_hint_profile_name"
android:textAlignment="center" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
我试过了什么
如果我改变了android.support.design.widget.CoordinatorLayout与LinearLayout该setError问题不会发生,但将在状态栏颜色更改为白色的,我的UI正在奇怪.
我是Android编程的新手,不知道发生了什么,请帮助我.
android android-linearlayout android-edittext android-coordinatorlayout
我使用2 UIView在xib文件中绘制不同的对象.在为某些操作绘制新对象之前,需要清除视图.最初,当对象类型的数量较少时,我一直在使用它:
for (UILabel *btn in self.contentView.subviews)
{
if([btn isKindOfClass:[UILabel class]])
{
[btn removeFromSuperview];
}
}
Run Code Online (Sandbox Code Playgroud)
但是当我有多个动作并且要为每个动作绘制多个类型的对象时,使用这种类型的方法看起来很糟糕.有没有一种有效的方法来做到这一点?